<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta name="generator" content="hevea 2.00"> <link rel="stylesheet" type="text/css" href="manual.css"> <title>The unix library: Unix system calls</title> </head> <body> <a href="stdlib.html"><img src="previous_motif.gif" alt="Previous"></a> <a href="index.html"><img src="contents_motif.gif" alt="Up"></a> <a href="libnum.html"><img src="next_motif.gif" alt="Next"></a> <hr> <h1 class="chapter" id="sec470">Chapter 22  The unix library: Unix system calls</h1> <p>The <span class="c007">unix</span> library makes many Unix system calls and system-related library functions available to OCaml programs. This chapter describes briefly the functions provided. Refer to sections 2 and 3 of the Unix manual for more details on the behavior of these functions.</p><p>Not all functions are provided by all Unix variants. If some functions are not available, they will raise <span class="c007">Invalid_arg</span> when called.</p><p>Programs that use the <span class="c007">unix</span> library must be linked as follows: </p><pre> ocamlc <span class="c013">other options</span> unix.cma <span class="c013">other files</span> ocamlopt <span class="c013">other options</span> unix.cmxa <span class="c013">other files</span> </pre><p> For interactive use of the <span class="c007">unix</span> library, do: </p><pre> ocamlmktop -o mytop unix.cma ./mytop </pre><p> or (if dynamic linking of C libraries is supported on your platform), start <span class="c007">ocaml</span> and type <span class="c007">#load "unix.cma";;</span>.</p><blockquote class="quote"><span class="c011">Windows:</span>   A fairly complete emulation of the Unix system calls is provided in the Windows version of OCaml. The end of this chapter gives more information on the functions that are not supported under Windows. </blockquote><ul class="ftoc2"><li class="li-links"> <a href="libref/Unix.html">Module <span class="c007">Unix</span>: Unix system calls</a> </li><li class="li-links"><a href="libref/UnixLabels.html">Module <span class="c007">UnixLabels</span>: Labeled Unix system calls</a> </li></ul><blockquote class="quote"><span class="c011">Windows:</span>   The Cygwin port of OCaml fully implements all functions from the Unix module. The native Win32 ports implement a subset of them. Below is a list of the functions that are not implemented, or only partially implemented, by the Win32 ports. Functions not mentioned are fully implemented and behave as described previously in this chapter.<div class="center"><table class="c001 cellpadding1" border=1><tr><td class="c021"><span class="c019">Functions</span></td><td class="c021"><span class="c019">Comment</span> </td></tr> <tr><td class="c029"> <span class="c007">fork</span></td><td class="c028">not implemented, use <span class="c007">create_process</span> or threads </td></tr> <tr><td class="c029"><span class="c007">wait</span></td><td class="c028">not implemented, use <span class="c007">waitpid</span> </td></tr> <tr><td class="c029"><span class="c007">waitpid</span></td><td class="c028">can only wait for a given PID, not any child process </td></tr> <tr><td class="c029"><span class="c007">getppid</span></td><td class="c028">not implemented (meaningless under Windows) </td></tr> <tr><td class="c029"><span class="c007">nice</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">truncate</span>, <span class="c007">ftruncate</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">link</span>, <span class="c007">symlink</span>, <span class="c007">readlink</span></td><td class="c028">not implemented (no links under Windows) </td></tr> <tr><td class="c029"><span class="c007">access</span></td><td class="c028">execute permission <span class="c007">X_OK</span> cannot be tested, it just tests for read permission instead </td></tr> <tr><td class="c029"><span class="c007">fchmod</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">chown</span>, <span class="c007">fchown</span></td><td class="c028">not implemented (make no sense on a DOS file system) </td></tr> <tr><td class="c029"><span class="c007">umask</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">mkfifo</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">kill</span>, <span class="c007">pause</span></td><td class="c028">not implemented (no inter-process signals in Windows) </td></tr> <tr><td class="c029"><span class="c007">alarm</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">times</span></td><td class="c028">partially implemented, will not report timings for child processes </td></tr> <tr><td class="c029"><span class="c007">getitimer</span>, <span class="c007">setitimer</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">getuid</span>, <span class="c007">getgid</span></td><td class="c028">always return 1 </td></tr> <tr><td class="c029"><span class="c007">getgid</span>, <span class="c007">getegid</span>, <span class="c007">getgroups</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">setuid</span>, <span class="c007">setgid</span></td><td class="c028">not implemented </td></tr> <tr><td class="c029"><span class="c007">getpwnam</span>, <span class="c007">getpwuid</span></td><td class="c028">always raise <span class="c007">Not_found</span> </td></tr> <tr><td class="c029"><span class="c007">getgrnam</span>, <span class="c007">getgrgid</span></td><td class="c028">always raise <span class="c007">Not_found</span> </td></tr> <tr><td class="c029">type <span class="c007">socket_domain</span></td><td class="c028">the domains <span class="c007">PF_UNIX</span> and <span class="c007">PF_INET6</span> are not supported; <span class="c007">PF_INET</span> is fully supported </td></tr> <tr><td class="c029"><span class="c007">establish_server</span></td><td class="c028">not implemented; use threads </td></tr> <tr><td class="c029">terminal functions (<span class="c007">tc*</span>)</td><td class="c028">not implemented </td></tr> </table></div></blockquote> <hr> <a href="stdlib.html"><img src="previous_motif.gif" alt="Previous"></a> <a href="index.html"><img src="contents_motif.gif" alt="Up"></a> <a href="libnum.html"><img src="next_motif.gif" alt="Next"></a> </body> </html>