8
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
9
<META name="GENERATOR" content="hevea 1.08">
7
<META name="GENERATOR" content="hevea 1.09">
10
8
<LINK rel="stylesheet" type="text/css" href="manual.css">
12
The unix library: Unix system calls
9
<TITLE>The unix library: Unix system calls</TITLE>
16
<A HREF="manual034.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
17
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
18
<A HREF="manual036.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
12
<A HREF="manual034.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
13
<A HREF="index.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
14
<A HREF="manual036.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
21
<H1 CLASS="chapter"><A NAME="htoc253">Chapter 21</A> The unix library: Unix system calls</H1>
23
The <TT>unix</TT> library makes many Unix
16
<H1 CLASS="chapter"><A NAME="htoc253">Chapter�21</A>��The unix library: Unix system calls</H1><P>The <TT>unix</TT> library makes many Unix
24
17
system calls and system-related library functions available to
25
18
Objective Caml programs. This chapter describes briefly the functions
26
provided. Refer to sections 2 and 3 of the Unix manual for more
27
details on the behavior of these functions.<BR>
29
Not all functions are provided by all Unix variants. If some functions
30
are not available, they will raise <TT>Invalid_arg</TT> when called.<BR>
32
Programs that use the <TT>unix</TT> library must be linked as follows:
19
provided. Refer to sections 2�and�3 of the Unix manual for more
20
details on the behavior of these functions.</P><P>Not all functions are provided by all Unix variants. If some functions
21
are not available, they will raise <TT>Invalid_arg</TT> when called.</P><P>Programs that use the <TT>unix</TT> library must be linked as follows:
34
23
ocamlc <I>other options</I> unix.cma <I>other files</I>
35
24
ocamlopt <I>other options</I> unix.cmxa <I>other files</I>
37
26
For interactive use of the <TT>unix</TT> library, do:
39
28
ocamlmktop -o mytop unix.cma
42
31
or (if dynamic linking of C libraries is supported on your platform),
43
start <TT>ocaml</TT> and type <TT>#load "unix.cma";;</TT>.<BR>
46
<FONT COLOR=purple>Windows:</FONT>
47
<BLOCKQUOTE CLASS="quote">
32
start <TT>ocaml</TT> and type <TT>#load "unix.cma";;</TT>.</P><BLOCKQUOTE CLASS="quote"><FONT COLOR=purple>Windows:</FONT>��
48
33
A fairly complete emulation of the Unix system calls is provided in
49
34
the Windows version of Objective Caml. The end of this chapter gives
50
35
more information on the functions that are not supported under Windows.
54
<li><a HREF="libref/Unix.html"> Module <tt>Unix</tt>: Unix system calls</a> <img alt="updated" src="updated_tiny.gif"></li>
55
<li><a HREF="libref/UnixLabels.html"> Module <tt>UnixLabels</tt>: Labeled Unix system calls</a></li>
60
<FONT COLOR=purple>Windows:</FONT>
61
<BLOCKQUOTE CLASS="quote">
36
</BLOCKQUOTE><UL CLASS="ftoc2"><LI CLASS="li-links">
37
<A HREF="libref/Unix.html">Module <TT>Unix</TT>: Unix system calls</A>
38
</LI><LI CLASS="li-links"><A HREF="libref/UnixLabels.html">Module <TT>UnixLabels</TT>: Labeled Unix system calls</A>
39
</LI></UL><BLOCKQUOTE CLASS="quote"><FONT COLOR=purple>Windows:</FONT>��
62
40
The Cygwin port of Objective Caml fully implements all functions from
63
41
the Unix module. The native Win32 ports implement a subset of them.
64
42
Below is a list of the functions that are not implemented, or only
65
43
partially implemented, by the Win32 ports. Functions not mentioned are
66
fully implemented and behave as described previously in this chapter.<BR>
68
<DIV CLASS="center"><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
69
<TR><TD ALIGN=center NOWRAP><B>Functions</B></TD>
70
<TD ALIGN=center NOWRAP><B>Comment</B></TD>
44
fully implemented and behave as described previously in this chapter.<DIV CLASS="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>
72
45
<TR><TD VALIGN=top ALIGN=left NOWRAP>
74
<TD VALIGN=top ALIGN=left>not implemented, use <TT>create_process</TT> or threads</TD>
76
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>wait</TT></TD>
77
<TD VALIGN=top ALIGN=left>not implemented, use <TT>waitpid</TT></TD>
79
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>waitpid</TT></TD>
80
<TD VALIGN=top ALIGN=left>can only wait for a given PID, not any child process</TD>
82
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getppid</TT></TD>
83
<TD VALIGN=top ALIGN=left>not implemented (meaningless under Windows)</TD>
85
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>nice</TT></TD>
86
<TD VALIGN=top ALIGN=left>not implemented</TD>
88
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>in_channel_of_descr</TT></TD>
89
<TD VALIGN=top ALIGN=left>does not work on sockets under Windows
90
95, 98, ME; works fine under NT, 2000, XP</TD>
92
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>out_channel_of_descr</TT></TD>
93
<TD VALIGN=top ALIGN=left>ditto</TD>
95
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>truncate</TT>, <TT>ftruncate</TT></TD>
96
<TD VALIGN=top ALIGN=left>not implemented</TD>
98
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lstat</TT>, <TT>fstat</TT></TD>
99
<TD VALIGN=top ALIGN=left>not implemented</TD>
101
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>link</TT>, <TT>symlink</TT>, <TT>readlink</TT></TD>
102
<TD VALIGN=top ALIGN=left>not implemented (no links under
105
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>fchmod</TT></TD>
106
<TD VALIGN=top ALIGN=left>not implemented</TD>
108
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>chown</TT>, <TT>fchown</TT></TD>
109
<TD VALIGN=top ALIGN=left>not implemented (make no sense on a DOS
112
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>umask</TT></TD>
113
<TD VALIGN=top ALIGN=left>not implemented</TD>
115
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>set_nonblock</TT>, <TT>clear_nonblock</TT></TD>
116
<TD VALIGN=top ALIGN=left>implemented as dummy
117
functions; use threads instead of non-blocking I/O</TD>
119
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>rewinddir</TT></TD>
120
<TD VALIGN=top ALIGN=left>not implemented; re-open the directory instead</TD>
122
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>mkfifo</TT></TD>
123
<TD VALIGN=top ALIGN=left>not implemented</TD>
125
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>select</TT></TD>
126
<TD VALIGN=top ALIGN=left>implemented, but works only for sockets; use threads
127
if you need to wait on other kinds of file descriptors</TD>
129
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lockf</TT></TD>
130
<TD VALIGN=top ALIGN=left>not implemented</TD>
132
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>kill</TT>, <TT>pause</TT></TD>
133
<TD VALIGN=top ALIGN=left>not implemented (no inter-process signals in Windows)</TD>
135
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>alarm</TT>, <TT>times</TT></TD>
136
<TD VALIGN=top ALIGN=left>not implemented</TD>
138
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getitimer</TT>, <TT>setitimer</TT></TD>
139
<TD VALIGN=top ALIGN=left>not implemented</TD>
141
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getuid</TT>, <TT>getgid</TT></TD>
142
<TD VALIGN=top ALIGN=left>always return 1</TD>
144
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getgid</TT>, <TT>getegid</TT>, <TT>getgroups</TT></TD>
145
<TD VALIGN=top ALIGN=left>not implemented</TD>
147
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>setuid</TT>, <TT>setgid</TT></TD>
148
<TD VALIGN=top ALIGN=left>not implemented</TD>
150
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getpwnam</TT>, <TT>getpwuid</TT></TD>
151
<TD VALIGN=top ALIGN=left>always raise <TT>Not_found</TT></TD>
153
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getgrnam</TT>, <TT>getgrgid</TT></TD>
154
<TD VALIGN=top ALIGN=left>always raise <TT>Not_found</TT></TD>
156
<TR><TD VALIGN=top ALIGN=left NOWRAP>type <TT>socket_domain</TT></TD>
157
<TD VALIGN=top ALIGN=left>the domain <TT>PF_UNIX</TT> is not supported;
158
<TT>PF_INET</TT> is fully supported</TD>
160
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>open_connection</TT></TD>
161
<TD VALIGN=top ALIGN=left>does not work under Windows
162
95, 98, ME; works fine under NT, 2000, XP</TD>
164
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>establish_server</TT></TD>
165
<TD VALIGN=top ALIGN=left>not implemented; use threads</TD>
167
<TR><TD VALIGN=top ALIGN=left NOWRAP>terminal functions (<TT>tc*</TT>)</TD>
168
<TD VALIGN=top ALIGN=left>not implemented</TD>
169
</TR></TABLE></DIV></BLOCKQUOTE>
174
<A HREF="manual034.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
175
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
176
<A HREF="manual036.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
46
<TT>fork</TT></TD><TD VALIGN=top ALIGN=left>not implemented, use <TT>create_process</TT> or threads</TD></TR>
47
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>wait</TT></TD><TD VALIGN=top ALIGN=left>not implemented, use <TT>waitpid</TT></TD></TR>
48
<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>
49
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getppid</TT></TD><TD VALIGN=top ALIGN=left>not implemented (meaningless under Windows)</TD></TR>
50
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>nice</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
51
<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
52
95, 98, ME; works fine under NT, 2000, XP</TD></TR>
53
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>out_channel_of_descr</TT></TD><TD VALIGN=top ALIGN=left>ditto</TD></TR>
54
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>truncate</TT>, <TT>ftruncate</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
55
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lstat</TT>, <TT>fstat</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
56
<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
58
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>fchmod</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
59
<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
60
file system)</TD></TR>
61
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>umask</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
62
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>set_nonblock</TT>, <TT>clear_nonblock</TT></TD><TD VALIGN=top ALIGN=left>implemented as dummy
63
functions; use threads instead of non-blocking I/O</TD></TR>
64
<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>
65
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>mkfifo</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
66
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>select</TT></TD><TD VALIGN=top ALIGN=left>implemented, but works only for sockets; use threads
67
if you need to wait on other kinds of file descriptors</TD></TR>
68
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>lockf</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
69
<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>
70
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>alarm</TT>, <TT>times</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
71
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getitimer</TT>, <TT>setitimer</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
72
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>getuid</TT>, <TT>getgid</TT></TD><TD VALIGN=top ALIGN=left>always return 1</TD></TR>
73
<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>
74
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>setuid</TT>, <TT>setgid</TT></TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
75
<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>
76
<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>
77
<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;
78
<TT>PF_INET</TT> is fully supported</TD></TR>
79
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>open_connection</TT></TD><TD VALIGN=top ALIGN=left>does not work under Windows
80
95, 98, ME; works fine under NT, 2000, XP</TD></TR>
81
<TR><TD VALIGN=top ALIGN=left NOWRAP><TT>establish_server</TT></TD><TD VALIGN=top ALIGN=left>not implemented; use threads</TD></TR>
82
<TR><TD VALIGN=top ALIGN=left NOWRAP>terminal functions (<TT>tc*</TT>)</TD><TD VALIGN=top ALIGN=left>not implemented</TD></TR>
83
</TABLE></DIV></BLOCKQUOTE><HR>
84
<A HREF="manual034.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
85
<A HREF="index.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
86
<A HREF="manual036.html"><IMG SRC="next_motif.gif" ALT="Next"></A>