blob: 803cbbcde18ad5bf89256311fc4e0f990a60644c [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in Module \sectcode{posix}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-posix}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00003\bimodindex{posix}
4
5This module provides access to operating system functionality that is
Guido van Rossum6bb1adc1995-03-13 10:03:32 +00006standardized by the C Standard and the POSIX standard (a thinly disguised
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00007\UNIX{} interface).
Guido van Rossum470be141995-03-17 16:07:09 +00008
9\strong{Do not import this module directly.} Instead, import the
10module \code{os}, which provides a \emph{portable} version of this
11interface. On \UNIX{}, the \code{os} module provides a superset of
12the \code{posix} interface. On non-\UNIX{} operating systems the
13\code{posix} module is not available, but a subset is always available
14through the \code{os} interface. Once \code{os} is imported, there is
15\emph{no} performance penalty in using it instead of
Guido van Rossum9c43c591997-08-08 21:05:09 +000016\code{posix}. In addition, \code{os} provides some additional
17functionality, such as automatically calling \code{putenv()}
18when an entry is \code{os.environ} is changed.
Fred Drake62063941997-12-15 21:42:51 +000019\refstmodindex{os}
Guido van Rossum470be141995-03-17 16:07:09 +000020
Guido van Rossum282290f1997-08-27 14:54:25 +000021The descriptions below are very terse; refer to the corresponding
22\UNIX{} manual (or POSIX documentation) entry for more information.
23Arguments called \var{path} refer to a pathname given as a string.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000024
25Errors are reported as exceptions; the usual exceptions are given
26for type errors, while errors reported by the system calls raise
27\code{posix.error}, described below.
28
29Module \code{posix} defines the following data items:
30
31\renewcommand{\indexsubitem}{(data in module posix)}
32\begin{datadesc}{environ}
33A dictionary representing the string environment at the time
34the interpreter was started.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000035For example,
36\code{posix.environ['HOME']}
37is the pathname of your home directory, equivalent to
38\code{getenv("HOME")}
39in C.
Guido van Rossum9c43c591997-08-08 21:05:09 +000040
Guido van Rossum470be141995-03-17 16:07:09 +000041Modifying this dictionary does not affect the string environment
42passed on by \code{execv()}, \code{popen()} or \code{system()}; if you
43need to change the environment, pass \code{environ} to \code{execve()}
44or add variable assignments and export statements to the command
Guido van Rossum9c43c591997-08-08 21:05:09 +000045string for \code{system()} or \code{popen()}.
46
47\emph{However:} If you are using this module via the \code{os} module
48(as you should -- see the introduction above), \code{environ} is a
49a mapping object that behaves almost like a dictionary but invokes
50\code{putenv()} automatically called whenever an item is changed.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000051\end{datadesc}
52
53\renewcommand{\indexsubitem}{(exception in module posix)}
54\begin{excdesc}{error}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000055This exception is raised when a POSIX function returns a
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000056POSIX-related error (e.g., not for illegal argument types). Its
57string value is \code{'posix.error'}. The accompanying value is a
58pair containing the numeric error code from \code{errno} and the
59corresponding string, as would be printed by the C function
60\code{perror()}.
Guido van Rossumf499e091998-02-06 15:18:05 +000061See the module \module{errno}\refbimodindex{errno}, which contains
62names for the error codes defined by the underlying operating system.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000063\end{excdesc}
64
Guido van Rossum4bbe9c01995-03-30 16:00:36 +000065It defines the following functions and constants:
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000066
67\renewcommand{\indexsubitem}{(in module posix)}
68\begin{funcdesc}{chdir}{path}
69Change the current working directory to \var{path}.
70\end{funcdesc}
71
72\begin{funcdesc}{chmod}{path\, mode}
73Change the mode of \var{path} to the numeric \var{mode}.
74\end{funcdesc}
75
Guido van Rossum31cce971995-01-04 19:17:34 +000076\begin{funcdesc}{chown}{path\, uid, gid}
77Change the owner and group id of \var{path} to the numeric \var{uid}
78and \var{gid}.
79(Not on MS-DOS.)
80\end{funcdesc}
81
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000082\begin{funcdesc}{close}{fd}
83Close file descriptor \var{fd}.
Guido van Rossum28379701995-01-12 12:38:22 +000084
85Note: this function is intended for low-level I/O and must be applied
86to a file descriptor as returned by \code{posix.open()} or
87\code{posix.pipe()}. To close a ``file object'' returned by the
88built-in function \code{open} or by \code{posix.popen} or
89\code{posix.fdopen}, use its \code{close()} method.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000090\end{funcdesc}
91
92\begin{funcdesc}{dup}{fd}
93Return a duplicate of file descriptor \var{fd}.
94\end{funcdesc}
95
96\begin{funcdesc}{dup2}{fd\, fd2}
97Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter
98first if necessary. Return \code{None}.
99\end{funcdesc}
100
101\begin{funcdesc}{execv}{path\, args}
102Execute the executable \var{path} with argument list \var{args},
103replacing the current process (i.e., the Python interpreter).
104The argument list may be a tuple or list of strings.
105(Not on MS-DOS.)
106\end{funcdesc}
107
108\begin{funcdesc}{execve}{path\, args\, env}
109Execute the executable \var{path} with argument list \var{args},
110and environment \var{env},
111replacing the current process (i.e., the Python interpreter).
112The argument list may be a tuple or list of strings.
113The environment must be a dictionary mapping strings to strings.
114(Not on MS-DOS.)
115\end{funcdesc}
116
117\begin{funcdesc}{_exit}{n}
118Exit to the system with status \var{n}, without calling cleanup
119handlers, flushing stdio buffers, etc.
120(Not on MS-DOS.)
121
122Note: the standard way to exit is \code{sys.exit(\var{n})}.
123\code{posix._exit()} should normally only be used in the child process
124after a \code{fork()}.
125\end{funcdesc}
126
Guido van Rossum28379701995-01-12 12:38:22 +0000127\begin{funcdesc}{fdopen}{fd\optional{\, mode\optional{\, bufsize}}}
128Return an open file object connected to the file descriptor \var{fd}.
129The \var{mode} and \var{bufsize} arguments have the same meaning as
130the corresponding arguments to the built-in \code{open()} function.
Guido van Rossumc5c67bc1994-02-15 15:59:23 +0000131\end{funcdesc}
132
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000133\begin{funcdesc}{fork}{}
134Fork a child process. Return 0 in the child, the child's process id
135in the parent.
136(Not on MS-DOS.)
137\end{funcdesc}
138
139\begin{funcdesc}{fstat}{fd}
140Return status for file descriptor \var{fd}, like \code{stat()}.
141\end{funcdesc}
142
Guido van Rossumf967bf61997-06-02 17:28:51 +0000143\begin{funcdesc}{ftruncate}{fd\, length}
144Truncate the file corresponding to file descriptor \var{fd},
145so that it is at most \var{length} bytes in size.
146\end{funcdesc}
147
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000148\begin{funcdesc}{getcwd}{}
149Return a string representing the current working directory.
150\end{funcdesc}
151
152\begin{funcdesc}{getegid}{}
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000153Return the current process' effective group id.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000154(Not on MS-DOS.)
155\end{funcdesc}
156
157\begin{funcdesc}{geteuid}{}
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000158Return the current process' effective user id.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000159(Not on MS-DOS.)
160\end{funcdesc}
161
162\begin{funcdesc}{getgid}{}
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000163Return the current process' group id.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000164(Not on MS-DOS.)
165\end{funcdesc}
166
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000167\begin{funcdesc}{getpgrp}{}
168Return the current process group id.
169(Not on MS-DOS.)
170\end{funcdesc}
171
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000172\begin{funcdesc}{getpid}{}
173Return the current process id.
174(Not on MS-DOS.)
175\end{funcdesc}
176
177\begin{funcdesc}{getppid}{}
178Return the parent's process id.
179(Not on MS-DOS.)
180\end{funcdesc}
181
182\begin{funcdesc}{getuid}{}
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000183Return the current process' user id.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000184(Not on MS-DOS.)
185\end{funcdesc}
186
187\begin{funcdesc}{kill}{pid\, sig}
188Kill the process \var{pid} with signal \var{sig}.
189(Not on MS-DOS.)
190\end{funcdesc}
191
192\begin{funcdesc}{link}{src\, dst}
193Create a hard link pointing to \var{src} named \var{dst}.
194(Not on MS-DOS.)
195\end{funcdesc}
196
197\begin{funcdesc}{listdir}{path}
198Return a list containing the names of the entries in the directory.
Guido van Rossum8c07bb41996-02-12 23:16:08 +0000199The list is in arbitrary order. It does not include the special
200entries \code{'.'} and \code{'..'} even if they are present in the
201directory.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000202\end{funcdesc}
203
204\begin{funcdesc}{lseek}{fd\, pos\, how}
205Set the current position of file descriptor \var{fd} to position
206\var{pos}, modified by \var{how}: 0 to set the position relative to
207the beginning of the file; 1 to set it relative to the current
208position; 2 to set it relative to the end of the file.
209\end{funcdesc}
210
211\begin{funcdesc}{lstat}{path}
212Like \code{stat()}, but do not follow symbolic links. (On systems
Fred Drake62063941997-12-15 21:42:51 +0000213without symbolic links, this is identical to \code{posix.stat()}.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000214\end{funcdesc}
215
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000216\begin{funcdesc}{mkfifo}{path\optional{\, mode}}
217Create a FIFO (a POSIX named pipe) named \var{path} with numeric mode
218\var{mode}. The default \var{mode} is 0666 (octal). The current
219umask value is first masked out from the mode.
220(Not on MS-DOS.)
221
222FIFOs are pipes that can be accessed like regular files. FIFOs exist
223until they are deleted (for example with \code{os.unlink}).
224Generally, FIFOs are used as rendez-vous between ``client'' and
225``server'' type processes: the server opens the FIFO for reading, and
226the client opens it for writing. Note that \code{mkfifo()} doesn't
227open the FIFO -- it just creates the rendez-vous point.
228\end{funcdesc}
229
230\begin{funcdesc}{mkdir}{path\optional{\, mode}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000231Create a directory named \var{path} with numeric mode \var{mode}.
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000232The default \var{mode} is 0777 (octal). On some systems, \var{mode}
233is ignored. Where it is used, the current umask value is first
234masked out.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000235\end{funcdesc}
236
237\begin{funcdesc}{nice}{increment}
238Add \var{incr} to the process' ``niceness''. Return the new niceness.
239(Not on MS-DOS.)
240\end{funcdesc}
241
Barry Warsawfa5a6cf1996-12-19 22:38:56 +0000242\begin{funcdesc}{open}{file\, flags\optional{\, mode}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000243Open the file \var{file} and set various flags according to
244\var{flags} and possibly its mode according to \var{mode}.
Barry Warsawfa5a6cf1996-12-19 22:38:56 +0000245The default \var{mode} is 0777 (octal), and the current umask value is
246first masked out. Return the file descriptor for the newly opened
247file.
Guido van Rossum28379701995-01-12 12:38:22 +0000248
Guido van Rossum9c43c591997-08-08 21:05:09 +0000249For a description of the flag and mode values, see the \UNIX{} or C
250run-time documentation; flag constants (like \code{O_RDONLY} and
251\code{O_WRONLY}) are defined in this module too (see below).
252
Guido van Rossum28379701995-01-12 12:38:22 +0000253Note: this function is intended for low-level I/O. For normal usage,
254use the built-in function \code{open}, which returns a ``file object''
255with \code{read()} and \code{write()} methods (and many more).
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000256\end{funcdesc}
257
258\begin{funcdesc}{pipe}{}
259Create a pipe. Return a pair of file descriptors \code{(r, w)}
260usable for reading and writing, respectively.
261(Not on MS-DOS.)
262\end{funcdesc}
263
Guido van Rossum38e50881996-07-21 02:21:49 +0000264\begin{funcdesc}{plock}{op}
265Lock program segments into memory. The value of \var{op}
266(defined in \code{<sys/lock.h>}) determines which segments are locked.
267(Not on MS-DOS.)
268\end{funcdesc}
269
Guido van Rossum28379701995-01-12 12:38:22 +0000270\begin{funcdesc}{popen}{command\optional{\, mode\optional{\, bufsize}}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000271Open a pipe to or from \var{command}. The return value is an open
272file object connected to the pipe, which can be read or written
Guido van Rossum28379701995-01-12 12:38:22 +0000273depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}.
274The \var{bufsize} argument has the same meaning as the corresponding
Guido van Rossum7e691de1997-05-09 02:22:59 +0000275argument to the built-in \code{open()} function. The exit status of
276the command (encoded in the format specified for \code{wait()}) is
277available as the return value of the \code{close()} method of the file
278object.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000279(Not on MS-DOS.)
280\end{funcdesc}
281
Guido van Rossumf967bf61997-06-02 17:28:51 +0000282\begin{funcdesc}{putenv}{varname\, value}
283Set the environment variable named \var{varname} to the string \var{value}.
284Such changes to the environment affect
285subprocesses started with \code{os.system()}, \code{os.popen()} or
286\code{os.fork()} and \code{os.execv()}. (Not on all systems.)
287
288When \code{putenv()} is
289supported, assignments to items in \code{os.environ} are automatically
290translated into corresponding calls to \code{os.putenv()}; however,
291calls to \code{os.putenv()} don't update \code{os.environ}, so it is
292actually preferable to assign to items of \code{os.environ}.
293\end{funcdesc}
294
Guido van Rossum0bfd1461997-10-05 18:54:52 +0000295\begin{funcdesc}{strerror}{code}
296Return the error message corresponding to the error code in \var{code}.
297\end{funcdesc}
298
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000299\begin{funcdesc}{read}{fd\, n}
300Read at most \var{n} bytes from file descriptor \var{fd}.
301Return a string containing the bytes read.
Guido van Rossum28379701995-01-12 12:38:22 +0000302
303Note: this function is intended for low-level I/O and must be applied
304to a file descriptor as returned by \code{posix.open()} or
305\code{posix.pipe()}. To read a ``file object'' returned by the
306built-in function \code{open} or by \code{posix.popen} or
307\code{posix.fdopen}, or \code{sys.stdin}, use its
308\code{read()} or \code{readline()} methods.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000309\end{funcdesc}
310
311\begin{funcdesc}{readlink}{path}
312Return a string representing the path to which the symbolic link
313points. (On systems without symbolic links, this always raises
314\code{posix.error}.)
315\end{funcdesc}
316
Guido van Rossum8c07bb41996-02-12 23:16:08 +0000317\begin{funcdesc}{remove}{path}
318Remove the file \var{path}. See \code{rmdir} below to remove a directory.
Guido van Rossumf967bf61997-06-02 17:28:51 +0000319This is identical to the \code{unlink} function documented below.
Guido van Rossum8c07bb41996-02-12 23:16:08 +0000320\end{funcdesc}
321
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000322\begin{funcdesc}{rename}{src\, dst}
323Rename the file or directory \var{src} to \var{dst}.
324\end{funcdesc}
325
326\begin{funcdesc}{rmdir}{path}
327Remove the directory \var{path}.
328\end{funcdesc}
329
330\begin{funcdesc}{setgid}{gid}
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000331Set the current process' group id.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000332(Not on MS-DOS.)
333\end{funcdesc}
334
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000335\begin{funcdesc}{setpgrp}{}
336Calls the system call \code{setpgrp()} or \code{setpgrp(0, 0)}
Fred Drake4b3f0311996-12-13 22:04:31 +0000337depending on which version is implemented (if any). See the \UNIX{}
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000338manual for the semantics.
339(Not on MS-DOS.)
340\end{funcdesc}
341
342\begin{funcdesc}{setpgid}{pid\, pgrp}
Fred Drake4b3f0311996-12-13 22:04:31 +0000343Calls the system call \code{setpgid()}. See the \UNIX{} manual for
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000344the semantics.
345(Not on MS-DOS.)
346\end{funcdesc}
347
348\begin{funcdesc}{setsid}{}
Fred Drake4b3f0311996-12-13 22:04:31 +0000349Calls the system call \code{setsid()}. See the \UNIX{} manual for the
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000350semantics.
351(Not on MS-DOS.)
352\end{funcdesc}
353
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000354\begin{funcdesc}{setuid}{uid}
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000355Set the current process' user id.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000356(Not on MS-DOS.)
357\end{funcdesc}
358
359\begin{funcdesc}{stat}{path}
Fred Drakeaf8a0151998-01-14 14:51:31 +0000360Perform a \emph{stat} system call on the given path. The return value
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000361is a tuple of at least 10 integers giving the most important (and
Fred Drakeaf8a0151998-01-14 14:51:31 +0000362portable) members of the \emph{stat} structure, in the order
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000363\code{st_mode},
364\code{st_ino},
365\code{st_dev},
366\code{st_nlink},
367\code{st_uid},
368\code{st_gid},
369\code{st_size},
370\code{st_atime},
371\code{st_mtime},
372\code{st_ctime}.
373More items may be added at the end by some implementations.
374(On MS-DOS, some items are filled with dummy values.)
375
376Note: The standard module \code{stat} defines functions and constants
377that are useful for extracting information from a stat structure.
Fred Drake62063941997-12-15 21:42:51 +0000378\refstmodindex{stat}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000379\end{funcdesc}
380
381\begin{funcdesc}{symlink}{src\, dst}
382Create a symbolic link pointing to \var{src} named \var{dst}. (On
383systems without symbolic links, this always raises
384\code{posix.error}.)
385\end{funcdesc}
386
387\begin{funcdesc}{system}{command}
388Execute the command (a string) in a subshell. This is implemented by
389calling the Standard C function \code{system()}, and has the same
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000390limitations. Changes to \code{posix.environ}, \code{sys.stdin} etc.\ are
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000391not reflected in the environment of the executed command. The return
Guido van Rossum7e691de1997-05-09 02:22:59 +0000392value is the exit status of the process encoded in the format
393specified for \code{wait()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000394\end{funcdesc}
395
Guido van Rossum1e8b63e1996-06-26 19:22:46 +0000396\begin{funcdesc}{tcgetpgrp}{fd}
397Return the process group associated with the terminal given by
398\var{fd} (an open file descriptor as returned by \code{posix.open()}).
399(Not on MS-DOS.)
400\end{funcdesc}
401
402\begin{funcdesc}{tcsetpgrp}{fd\, pg}
403Set the process group associated with the terminal given by
404\var{fd} (an open file descriptor as returned by \code{posix.open()})
405to \var{pg}.
406(Not on MS-DOS.)
407\end{funcdesc}
408
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000409\begin{funcdesc}{times}{}
Guido van Rossum1e150611995-09-13 17:36:35 +0000410Return a 5-tuple of floating point numbers indicating accumulated (CPU
411or other)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000412times, in seconds. The items are: user time, system time, children's
Guido van Rossum1e150611995-09-13 17:36:35 +0000413user time, children's system time, and elapsed real time since a fixed
414point in the past, in that order. See the \UNIX{}
Fred Drakeca12b9d1998-01-20 04:43:29 +0000415manual page \emph{times}(2). (Not on MS-DOS.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000416\end{funcdesc}
417
418\begin{funcdesc}{umask}{mask}
419Set the current numeric umask and returns the previous umask.
420(Not on MS-DOS.)
421\end{funcdesc}
422
423\begin{funcdesc}{uname}{}
424Return a 5-tuple containing information identifying the current
425operating system. The tuple contains 5 strings:
426\code{(\var{sysname}, \var{nodename}, \var{release}, \var{version}, \var{machine})}.
427Some systems truncate the nodename to 8
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000428characters or to the leading component; a better way to get the
Guido van Rossumeb0f0661997-12-30 20:38:16 +0000429hostname is \code{socket.gethostname()} or even
430\code{socket.gethostbyaddr(socket.gethostname())}.
431(Not on MS-DOS, nor on older \UNIX{} systems.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000432\end{funcdesc}
433
434\begin{funcdesc}{unlink}{path}
Guido van Rossum8c07bb41996-02-12 23:16:08 +0000435Remove the file \var{path}. This is the same function as \code{remove};
436the \code{unlink} name is its traditional \UNIX{} name.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000437\end{funcdesc}
438
Fred Drake455838a1997-06-06 21:57:35 +0000439\begin{funcdesc}{utime}{path\, {\rm (}atime, mtime{\rm )}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000440Set the access and modified time of the file to the given values.
441(The second argument is a tuple of two items.)
442\end{funcdesc}
443
444\begin{funcdesc}{wait}{}
445Wait for completion of a child process, and return a tuple containing
Guido van Rossum7e691de1997-05-09 02:22:59 +0000446its pid and exit status indication: a 16-bit number, whose low byte is
447the signal number that killed the process, and whose high byte is the
448exit status (if the signal number is zero); the high bit of the low
449byte is set if a core file was produced. (Not on MS-DOS.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000450\end{funcdesc}
451
452\begin{funcdesc}{waitpid}{pid\, options}
453Wait for completion of a child process given by proces id, and return
Guido van Rossum7e691de1997-05-09 02:22:59 +0000454a tuple containing its pid and exit status indication (encoded as for
455\code{wait()}). The semantics of the call are affected by the value of
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000456the integer options, which should be 0 for normal operation. (If the
Guido van Rossum96628a91995-04-10 11:34:00 +0000457system does not support \code{waitpid()}, this always raises
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000458\code{posix.error}. Not on MS-DOS.)
459\end{funcdesc}
460
461\begin{funcdesc}{write}{fd\, str}
462Write the string \var{str} to file descriptor \var{fd}.
463Return the number of bytes actually written.
Guido van Rossum28379701995-01-12 12:38:22 +0000464
465Note: this function is intended for low-level I/O and must be applied
466to a file descriptor as returned by \code{posix.open()} or
467\code{posix.pipe()}. To write a ``file object'' returned by the
468built-in function \code{open} or by \code{posix.popen} or
469\code{posix.fdopen}, or \code{sys.stdout} or \code{sys.stderr}, use
470its \code{write()} method.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000471\end{funcdesc}
Guido van Rossum4bbe9c01995-03-30 16:00:36 +0000472
473\begin{datadesc}{WNOHANG}
474The option for \code{waitpid()} to avoid hanging if no child process
475status is available immediately.
476\end{datadesc}
Barry Warsawe5a43a41996-12-19 23:50:34 +0000477
478
479\begin{datadesc}{O_RDONLY}
480\end{datadesc}
481\begin{datadesc}{O_WRONLY}
482\end{datadesc}
483\begin{datadesc}{O_RDWR}
484\end{datadesc}
485\begin{datadesc}{O_NDELAY}
486\end{datadesc}
487\begin{datadesc}{O_NONBLOCK}
488\end{datadesc}
489\begin{datadesc}{O_APPEND}
490\end{datadesc}
491\begin{datadesc}{O_DSYNC}
492\end{datadesc}
493\begin{datadesc}{O_RSYNC}
494\end{datadesc}
495\begin{datadesc}{O_SYNC}
496\end{datadesc}
497\begin{datadesc}{O_NOCTTY}
498\end{datadesc}
499\begin{datadesc}{O_CREAT}
500\end{datadesc}
501\begin{datadesc}{O_EXCL}
502\end{datadesc}
503\begin{datadesc}{O_TRUNC}
504Options for the \code{flag} argument to the \code{open()} function.
505These can be bit-wise OR'd together.
506\end{datadesc}