<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14"> <TITLE> The unix library: Unix system calls </TITLE> </HEAD> <BODY TEXT=black BGCOLOR=white> <A HREF="manual034.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual036.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> <HR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#2de52d"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc244"><B><FONT SIZE=6>Chapter 21</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=6>The unix library: Unix system calls</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <BR> The <TT>unix</TT> library makes many Unix system calls and system-related library functions available to Objective Caml 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.<BR> <BR> Not all functions are provided by all Unix variants. If some functions are not available, they will raise <TT>Invalid_arg</TT> when called.<BR> <BR> Programs that use the <TT>unix</TT> library must be linked as follows: <PRE> ocamlc <I>other options</I> unix.cma <I>other files</I> ocamlopt <I>other options</I> unix.cmxa <I>other files</I> </PRE> For interactive use of the <TT>unix</TT> library, do: <PRE> ocamlmktop -o mytop unix.cma ./mytop </PRE> or (if dynamic linking of C libraries is supported on your platform), start <TT>ocaml</TT> and type <TT>#load "unix.cma";;</TT>.<BR> <BR> <FONT COLOR=purple>MacOS:</FONT> <BLOCKQUOTE> A fairly complete emulation of the Unix system calls is provided in the MacOS version of Objective Caml. The end of this chapter gives more information on the functions that are not supported under MacOS. </BLOCKQUOTE> <FONT COLOR=purple>Windows:</FONT> <BLOCKQUOTE> A fairly complete emulation of the Unix system calls is provided in the Windows version of Objective Caml. The end of this chapter gives more information on the functions that are not supported under Windows. </BLOCKQUOTE> <ul> <li><a HREF=libref/Unix.html> Module <tt>Unix</tt>: Unix system calls</a></li> <li><a HREF=libref/UnixLabels.html> Module <tt>UnixLabels</tt>: Labeled Unix system calls</a></li> </ul> <BR> <BR> <FONT COLOR=purple>MacOS:</FONT> <BLOCKQUOTE> Under MacOS, the Unix library is only available in the toplevel application, not in MPW tools. Below is a list of the functions that are not implemented, or only partially implemented, under MacOS. Functions not mentioned are fully implemented and behave as described previously in this chapter.<BR> <DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"> <TR><TD ALIGN=center NOWRAP><B>Functions</B></TD> <TD ALIGN=center NOWRAP><B>Comment</B></TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP> <TT>chown</TT>, <TT>fchown</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>chroot</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>environment</TT>, <TT>putenv</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>execv</TT>, <TT>execve</TT>, <TT>execvp</TT>, <TT>execvpe</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>fork</TT></TD> <TD VALIGN=top ALIGN=left>not implemented, use threads</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getegid</TT>, <TT>geteuid</TT>, <TT>getgid</TT>, <TT>getuid</TT></TD> <TD VALIGN=top ALIGN=left>always return 1</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getgrnam</TT>, <TT>getgrgid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getlogin</TT></TD> <TD VALIGN=top ALIGN=left>returns the user name as set in the Internet control panel</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getpid</TT></TD> <TD VALIGN=top ALIGN=left>returns the low-order 31 bits of the PSN</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getppid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getpwnam</TT>, <TT>getpwuid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>kill</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>link</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>mkfifo</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>nice</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>setgid</TT>, <TT>setuid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>times</TT></TD> <TD VALIGN=top ALIGN=left>only the process user time is returned</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>umask</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>wait</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>waitpid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>establish_server</TT></TD> <TD VALIGN=top ALIGN=left>not implemented; use threads</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP>terminal functions (<TT>tc*</TT>)</TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR></TABLE></DIV></BLOCKQUOTE> <FONT COLOR=purple>Windows:</FONT> <BLOCKQUOTE> The Cygwin port of Objective Caml fully implements all functions from the Unix module. The native Win32 port implements a subset of them. Below is a list of the functions that are not implemented, or only partially implemented, by the Win32 port. Functions not mentioned are fully implemented and behave as described previously in this chapter.<BR> <DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"> <TR><TD ALIGN=center NOWRAP><B>Functions</B></TD> <TD ALIGN=center NOWRAP><B>Comment</B></TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP> <TT>fork</TT></TD> <TD VALIGN=top ALIGN=left>not implemented, use <TT>create_process</TT> or threads</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>wait</TT></TD> <TD VALIGN=top ALIGN=left>not implemented, use <TT>waitpid</TT></TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>waitpid</TT></TD> <TD VALIGN=top ALIGN=left>can only wait for a given PID, not any child process</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getppid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented (meaningless under Windows)</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>nice</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>in_channel_of_descr</TT></TD> <TD VALIGN=top ALIGN=left>does not work on sockets under Windows 95, 98, ME; works fine under NT and 2000</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>out_channel_of_descr</TT></TD> <TD VALIGN=top ALIGN=left>ditto</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>truncate</TT>, <TT>ftruncate</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lstat</TT>, <TT>fstat</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>link</TT>, <TT>symlink</TT>, <TT>readlink</TT></TD> <TD VALIGN=top ALIGN=left>not implemented (no links under Windows)</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>fchmod</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>chown</TT>, <TT>fchown</TT></TD> <TD VALIGN=top ALIGN=left>not implemented (make no sense on a DOS file system)</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>umask</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>set_nonblock</TT>, <TT>clear_nonblock</TT></TD> <TD VALIGN=top ALIGN=left>implemented as dummy functions; use threads instead of non-blocking I/O</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>rewinddir</TT></TD> <TD VALIGN=top ALIGN=left>not implemented; re-open the directory instead</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>mkfifo</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>select</TT></TD> <TD VALIGN=top ALIGN=left>implemented, but works only for sockets; use threads if you need to wait on other kinds of file descriptors</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lockf</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>kill</TT>, <TT>pause</TT></TD> <TD VALIGN=top ALIGN=left>not implemented (no inter-process signals in Windows)</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>alarm</TT>, <TT>times</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getitimer</TT>, <TT>setitimer</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getuid</TT>, <TT>getgid</TT></TD> <TD VALIGN=top ALIGN=left>always return 1</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getgid</TT>, <TT>getegid</TT>, <TT>getgroups</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>setuid</TT>, <TT>setgid</TT></TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getpwnam</TT>, <TT>getpwuid</TT></TD> <TD VALIGN=top ALIGN=left>always raise <TT>Not_found</TT></TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getgrnam</TT>, <TT>getgrgid</TT></TD> <TD VALIGN=top ALIGN=left>always raise <TT>Not_found</TT></TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP>type <TT>socket_domain</TT></TD> <TD VALIGN=top ALIGN=left>the domain <TT>PF_UNIX</TT> is not supported; <TT>PF_INET</TT> is fully supported</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP><TT>establish_server</TT></TD> <TD VALIGN=top ALIGN=left>not implemented; use threads</TD> </TR> <TR><TD VALIGN=top ALIGN=left NOWRAP>terminal functions (<TT>tc*</TT>)</TD> <TD VALIGN=top ALIGN=left>not implemented</TD> </TR></TABLE></DIV></BLOCKQUOTE> <HR> <A HREF="manual034.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual036.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> </BODY> </HTML>