Logical markup.

Added information on the exception attributes when exceptions are classes.
This commit is contained in:
Fred Drake 1998-03-11 05:29:58 +00:00
parent e2e904f303
commit 75aae9ad89
2 changed files with 278 additions and 244 deletions

View file

@ -3,19 +3,19 @@
\bimodindex{posix} \bimodindex{posix}
This module provides access to operating system functionality that is This module provides access to operating system functionality that is
standardized by the C Standard and the \POSIX{} standard (a thinly disguised standardized by the \C{} Standard and the \POSIX{} standard (a thinly
\UNIX{} interface). disguised \UNIX{} interface).
\strong{Do not import this module directly.} Instead, import the \strong{Do not import this module directly.} Instead, import the
module \code{os}, which provides a \emph{portable} version of this module \module{os}, which provides a \emph{portable} version of this
interface. On \UNIX{}, the \code{os} module provides a superset of interface. On \UNIX{}, the \module{os} module provides a superset of
the \code{posix} interface. On non-\UNIX{} operating systems the the \module{posix} interface. On non-\UNIX{} operating systems the
\code{posix} module is not available, but a subset is always available \module{posix} module is not available, but a subset is always
through the \code{os} interface. Once \code{os} is imported, there is available through the \module{os} interface. Once \module{os} is
\emph{no} performance penalty in using it instead of imported, there is \emph{no} performance penalty in using it instead
\code{posix}. In addition, \code{os} provides some additional of \module{posix}. In addition, \module{os} provides some additional
functionality, such as automatically calling \code{putenv()} functionality, such as automatically calling \function{putenv()}
when an entry is \code{os.environ} is changed. when an entry in \code{os.environ} is changed.
\refstmodindex{os} \refstmodindex{os}
The descriptions below are very terse; refer to the corresponding The descriptions below are very terse; refer to the corresponding
@ -24,9 +24,9 @@ Arguments called \var{path} refer to a pathname given as a string.
Errors are reported as exceptions; the usual exceptions are given Errors are reported as exceptions; the usual exceptions are given
for type errors, while errors reported by the system calls raise for type errors, while errors reported by the system calls raise
\code{posix.error}, described below. \exception{error}, described below.
Module \code{posix} defines the following data items: Module \module{posix} defines the following data items:
\setindexsubitem{(data in module posix)} \setindexsubitem{(data in module posix)}
\begin{datadesc}{environ} \begin{datadesc}{environ}
@ -36,30 +36,40 @@ For example,
\code{posix.environ['HOME']} \code{posix.environ['HOME']}
is the pathname of your home directory, equivalent to is the pathname of your home directory, equivalent to
\code{getenv("HOME")} \code{getenv("HOME")}
in C. in \C{}.
Modifying this dictionary does not affect the string environment Modifying this dictionary does not affect the string environment
passed on by \code{execv()}, \code{popen()} or \code{system()}; if you passed on by \function{execv()}, \function{popen()} or
need to change the environment, pass \code{environ} to \code{execve()} \function{system()}; if you need to change the environment, pass
or add variable assignments and export statements to the command \code{environ} to \function{execve()} or add variable assignments and
string for \code{system()} or \code{popen()}. export statements to the command string for \function{system()} or
\function{popen()}.
\emph{However:} If you are using this module via the \code{os} module \emph{However:} If you are using this module via the \module{os}
(as you should -- see the introduction above), \code{environ} is a module (as you should -- see the introduction above), \code{environ}
a mapping object that behaves almost like a dictionary but invokes is a a mapping object that behaves almost like a dictionary but
\code{putenv()} automatically called whenever an item is changed. invokes \function{putenv()} automatically called whenever an item is
changed.
\end{datadesc} \end{datadesc}
\setindexsubitem{(exception in module posix)} \setindexsubitem{(exception in module posix)}
\begin{excdesc}{error} \begin{excdesc}{error}
This exception is raised when a \POSIX{} function returns a This exception is raised when a \POSIX{} function returns a
\POSIX{}-related error (e.g., not for illegal argument types). Its \POSIX{}-related error (e.g., not for illegal argument types). The
string value is \code{'posix.error'}. The accompanying value is a accompanying value is a pair containing the numeric error code from
pair containing the numeric error code from \code{errno} and the \cdata{errno} and the corresponding string, as would be printed by the
corresponding string, as would be printed by the C function \C{} function \cfunction{perror()}. See the module
\code{perror()}. \module{errno}\refbimodindex{errno}, which contains names for the
See the module \module{errno}\refbimodindex{errno}, which contains error codes defined by the underlying operating system.
names for the error codes defined by the underlying operating system.
When exceptions are classes, this exception carries two attributes,
\member{errno} and \member{strerror}. The first holds the value of
the \C{} \cdata{errno} variable, and the latter holds the
corresponding error message from \cfunction{strerror()}.
When exceptions are strings, the string for the exception is
\code{'os.error'}; this reflects the more portable access to the
exception through the \module{os} module.
\end{excdesc} \end{excdesc}
It defines the following functions and constants: It defines the following functions and constants:
@ -83,10 +93,10 @@ and \var{gid}.
Close file descriptor \var{fd}. Close file descriptor \var{fd}.
Note: this function is intended for low-level I/O and must be applied Note: this function is intended for low-level I/O and must be applied
to a file descriptor as returned by \code{posix.open()} or to a file descriptor as returned by \function{open()} or
\code{posix.pipe()}. To close a ``file object'' returned by the \function{pipe()}. To close a ``file object'' returned by the
built-in function \code{open} or by \code{posix.popen} or built-in function \function{open()} or by \function{popen()} or
\code{posix.fdopen}, use its \code{close()} method. \function{fdopen()}, use its \method{close()} method.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{dup}{fd} \begin{funcdesc}{dup}{fd}
@ -95,7 +105,7 @@ Return a duplicate of file descriptor \var{fd}.
\begin{funcdesc}{dup2}{fd\, fd2} \begin{funcdesc}{dup2}{fd\, fd2}
Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter
first if necessary. Return \code{None}. first if necessary.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{execv}{path\, args} \begin{funcdesc}{execv}{path\, args}
@ -120,24 +130,24 @@ handlers, flushing stdio buffers, etc.
(Not on MS-DOS.) (Not on MS-DOS.)
Note: the standard way to exit is \code{sys.exit(\var{n})}. Note: the standard way to exit is \code{sys.exit(\var{n})}.
\code{posix._exit()} should normally only be used in the child process \function{_exit()} should normally only be used in the child process
after a \code{fork()}. after a \function{fork()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fdopen}{fd\optional{\, mode\optional{\, bufsize}}} \begin{funcdesc}{fdopen}{fd\optional{\, mode\optional{\, bufsize}}}
Return an open file object connected to the file descriptor \var{fd}. Return an open file object connected to the file descriptor \var{fd}.
The \var{mode} and \var{bufsize} arguments have the same meaning as The \var{mode} and \var{bufsize} arguments have the same meaning as
the corresponding arguments to the built-in \code{open()} function. the corresponding arguments to the built-in \function{open()} function.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fork}{} \begin{funcdesc}{fork}{}
Fork a child process. Return 0 in the child, the child's process id Fork a child process. Return \code{0} in the child, the child's
in the parent. process id in the parent.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fstat}{fd} \begin{funcdesc}{fstat}{fd}
Return status for file descriptor \var{fd}, like \code{stat()}. Return status for file descriptor \var{fd}, like \function{stat()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{ftruncate}{fd\, length} \begin{funcdesc}{ftruncate}{fd\, length}
@ -203,61 +213,63 @@ directory.
\begin{funcdesc}{lseek}{fd\, pos\, how} \begin{funcdesc}{lseek}{fd\, pos\, how}
Set the current position of file descriptor \var{fd} to position Set the current position of file descriptor \var{fd} to position
\var{pos}, modified by \var{how}: 0 to set the position relative to \var{pos}, modified by \var{how}: \code{0} to set the position
the beginning of the file; 1 to set it relative to the current relative to the beginning of the file; \code{1} to set it relative to
position; 2 to set it relative to the end of the file. the current position; \code{2} to set it relative to the end of the
file.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{lstat}{path} \begin{funcdesc}{lstat}{path}
Like \code{stat()}, but do not follow symbolic links. (On systems Like \function{stat()}, but do not follow symbolic links. (On systems
without symbolic links, this is identical to \code{posix.stat()}.) without symbolic links, this is identical to \function{stat()}.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mkfifo}{path\optional{\, mode}} \begin{funcdesc}{mkfifo}{path\optional{\, mode}}
Create a FIFO (a \POSIX{} named pipe) named \var{path} with numeric mode Create a FIFO (a \POSIX{} named pipe) named \var{path} with numeric mode
\var{mode}. The default \var{mode} is 0666 (octal). The current \var{mode}. The default \var{mode} is \code{0666} (octal). The current
umask value is first masked out from the mode. umask value is first masked out from the mode.
(Not on MS-DOS.) (Not on MS-DOS.)
FIFOs are pipes that can be accessed like regular files. FIFOs exist FIFOs are pipes that can be accessed like regular files. FIFOs exist
until they are deleted (for example with \code{os.unlink}). until they are deleted (for example with \function{os.unlink()}).
Generally, FIFOs are used as rendez-vous between ``client'' and Generally, FIFOs are used as rendezvous between ``client'' and
``server'' type processes: the server opens the FIFO for reading, and ``server'' type processes: the server opens the FIFO for reading, and
the client opens it for writing. Note that \code{mkfifo()} doesn't the client opens it for writing. Note that \function{mkfifo()}
open the FIFO -- it just creates the rendez-vous point. doesn't open the FIFO --- it just creates the rendezvous point.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mkdir}{path\optional{\, mode}} \begin{funcdesc}{mkdir}{path\optional{\, mode}}
Create a directory named \var{path} with numeric mode \var{mode}. Create a directory named \var{path} with numeric mode \var{mode}.
The default \var{mode} is 0777 (octal). On some systems, \var{mode} The default \var{mode} is \code{0777} (octal). On some systems,
is ignored. Where it is used, the current umask value is first \var{mode} is ignored. Where it is used, the current umask value is
masked out. first masked out.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{nice}{increment} \begin{funcdesc}{nice}{increment}
Add \var{incr} to the process' ``niceness''. Return the new niceness. Add \var{increment} to the process' ``niceness''. Return the new
(Not on MS-DOS.) niceness. (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{open}{file\, flags\optional{\, mode}} \begin{funcdesc}{open}{file\, flags\optional{\, mode}}
Open the file \var{file} and set various flags according to Open the file \var{file} and set various flags according to
\var{flags} and possibly its mode according to \var{mode}. \var{flags} and possibly its mode according to \var{mode}.
The default \var{mode} is 0777 (octal), and the current umask value is The default \var{mode} is \code{0777} (octal), and the current umask
first masked out. Return the file descriptor for the newly opened value is first masked out. Return the file descriptor for the newly
file. opened file.
For a description of the flag and mode values, see the \UNIX{} or C For a description of the flag and mode values, see the \UNIX{} or \C{}
run-time documentation; flag constants (like \code{O_RDONLY} and run-time documentation; flag constants (like \constant{O_RDONLY} and
\code{O_WRONLY}) are defined in this module too (see below). \constant{O_WRONLY}) are defined in this module too (see below).
Note: this function is intended for low-level I/O. For normal usage, Note: this function is intended for low-level I/O. For normal usage,
use the built-in function \code{open}, which returns a ``file object'' use the built-in function \function{open()}, which returns a ``file
with \code{read()} and \code{write()} methods (and many more). object'' with \method{read()} and \method{write()} methods (and many
more).
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{pipe}{} \begin{funcdesc}{pipe}{}
Create a pipe. Return a pair of file descriptors \code{(r, w)} Create a pipe. Return a pair of file descriptors \code{(\var{r},
usable for reading and writing, respectively. \var{w})} usable for reading and writing, respectively.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
@ -272,23 +284,23 @@ Open a pipe to or from \var{command}. The return value is an open
file object connected to the pipe, which can be read or written file object connected to the pipe, which can be read or written
depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}. depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}.
The \var{bufsize} argument has the same meaning as the corresponding The \var{bufsize} argument has the same meaning as the corresponding
argument to the built-in \code{open()} function. The exit status of argument to the built-in \function{open()} function. The exit status of
the command (encoded in the format specified for \code{wait()}) is the command (encoded in the format specified for \function{wait()}) is
available as the return value of the \code{close()} method of the file available as the return value of the \method{close()} method of the file
object. object.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{putenv}{varname\, value} \begin{funcdesc}{putenv}{varname\, value}
Set the environment variable named \var{varname} to the string \var{value}. Set the environment variable named \var{varname} to the string
Such changes to the environment affect \var{value}. Such changes to the environment affect subprocesses
subprocesses started with \code{os.system()}, \code{os.popen()} or started with \function{os.system()}, \function{os.popen()} or
\code{os.fork()} and \code{os.execv()}. (Not on all systems.) \function{os.fork()} and \function{os.execv()}. (Not on all systems.)
When \code{putenv()} is When \function{putenv()} is
supported, assignments to items in \code{os.environ} are automatically supported, assignments to items in \code{os.environ} are automatically
translated into corresponding calls to \code{os.putenv()}; however, translated into corresponding calls to \function{putenv()}; however,
calls to \code{os.putenv()} don't update \code{os.environ}, so it is calls to \function{putenv()} don't update \code{os.environ}, so it is
actually preferable to assign to items of \code{os.environ}. actually preferable to assign to items of \code{os.environ}.
\end{funcdesc} \end{funcdesc}
@ -301,22 +313,23 @@ Read at most \var{n} bytes from file descriptor \var{fd}.
Return a string containing the bytes read. Return a string containing the bytes read.
Note: this function is intended for low-level I/O and must be applied Note: this function is intended for low-level I/O and must be applied
to a file descriptor as returned by \code{posix.open()} or to a file descriptor as returned by \function{open()} or
\code{posix.pipe()}. To read a ``file object'' returned by the \function{pipe()}. To read a ``file object'' returned by the
built-in function \code{open} or by \code{posix.popen} or built-in function \function{open()} or by \function{popen()} or
\code{posix.fdopen}, or \code{sys.stdin}, use its \function{fdopen()}, or \code{sys.stdin}, use its
\code{read()} or \code{readline()} methods. \method{read()} or \method{readline()} methods.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{readlink}{path} \begin{funcdesc}{readlink}{path}
Return a string representing the path to which the symbolic link Return a string representing the path to which the symbolic link
points. (On systems without symbolic links, this always raises points. (On systems without symbolic links, this always raises
\code{posix.error}.) \exception{error}.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{remove}{path} \begin{funcdesc}{remove}{path}
Remove the file \var{path}. See \code{rmdir} below to remove a directory. Remove the file \var{path}. See \function{rmdir()} below to remove a
This is identical to the \code{unlink} function documented below. directory. This is identical to the \function{unlink()} function
documented below.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{rename}{src\, dst} \begin{funcdesc}{rename}{src\, dst}
@ -333,21 +346,21 @@ Set the current process' group id.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setpgrp}{} \begin{funcdesc}{setpgrp}{}
Calls the system call \code{setpgrp()} or \code{setpgrp(0, 0)} Calls the system call \cfunction{setpgrp()} or \cfunction{setpgrp(0,
depending on which version is implemented (if any). See the \UNIX{} 0)} depending on which version is implemented (if any). See the
manual for the semantics. \UNIX{} manual for the semantics.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setpgid}{pid\, pgrp} \begin{funcdesc}{setpgid}{pid\, pgrp}
Calls the system call \code{setpgid()}. See the \UNIX{} manual for Calls the system call \cfunction{setpgid()}. See the \UNIX{} manual
the semantics. for the semantics.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setsid}{} \begin{funcdesc}{setsid}{}
Calls the system call \code{setsid()}. See the \UNIX{} manual for the Calls the system call \cfunction{setsid()}. See the \UNIX{} manual
semantics. for the semantics.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
@ -357,9 +370,10 @@ Set the current process' user id.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{stat}{path} \begin{funcdesc}{stat}{path}
Perform a \emph{stat} system call on the given path. The return value Perform a \cfunction{stat()} system call on the given path. The
is a tuple of at least 10 integers giving the most important (and return value is a tuple of at least 10 integers giving the most
portable) members of the \emph{stat} structure, in the order important (and portable) members of the \emph{stat} structure, in the
order
\code{st_mode}, \code{st_mode},
\code{st_ino}, \code{st_ino},
\code{st_dev}, \code{st_dev},
@ -373,35 +387,34 @@ portable) members of the \emph{stat} structure, in the order
More items may be added at the end by some implementations. More items may be added at the end by some implementations.
(On MS-DOS, some items are filled with dummy values.) (On MS-DOS, some items are filled with dummy values.)
Note: The standard module \code{stat} defines functions and constants Note: The standard module \module{stat}\refstmodindex{stat} defines
that are useful for extracting information from a stat structure. functions and constants that are useful for extracting information
\refstmodindex{stat} from a stat structure.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{symlink}{src\, dst} \begin{funcdesc}{symlink}{src\, dst}
Create a symbolic link pointing to \var{src} named \var{dst}. (On Create a symbolic link pointing to \var{src} named \var{dst}. (On
systems without symbolic links, this always raises systems without symbolic links, this always raises \exception{error}.)
\code{posix.error}.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{system}{command} \begin{funcdesc}{system}{command}
Execute the command (a string) in a subshell. This is implemented by Execute the command (a string) in a subshell. This is implemented by
calling the Standard C function \code{system()}, and has the same calling the Standard \C{} function \cfunction{system()}, and has the
limitations. Changes to \code{posix.environ}, \code{sys.stdin} etc.\ are same limitations. Changes to \code{posix.environ}, \code{sys.stdin}
not reflected in the environment of the executed command. The return etc.\ are not reflected in the environment of the executed command.
value is the exit status of the process encoded in the format The return value is the exit status of the process encoded in the
specified for \code{wait()}. format specified for \function{wait()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{tcgetpgrp}{fd} \begin{funcdesc}{tcgetpgrp}{fd}
Return the process group associated with the terminal given by Return the process group associated with the terminal given by
\var{fd} (an open file descriptor as returned by \code{posix.open()}). \var{fd} (an open file descriptor as returned by \function{open()}).
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{tcsetpgrp}{fd\, pg} \begin{funcdesc}{tcsetpgrp}{fd\, pg}
Set the process group associated with the terminal given by Set the process group associated with the terminal given by
\var{fd} (an open file descriptor as returned by \code{posix.open()}) \var{fd} (an open file descriptor as returned by \function{open()})
to \var{pg}. to \var{pg}.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
@ -412,7 +425,7 @@ or other)
times, in seconds. The items are: user time, system time, children's times, in seconds. The items are: user time, system time, children's
user time, children's system time, and elapsed real time since a fixed user time, children's system time, and elapsed real time since a fixed
point in the past, in that order. See the \UNIX{} point in the past, in that order. See the \UNIX{}
manual page \emph{times}(2). (Not on MS-DOS.) manual page \manpage{times}{2}. (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{umask}{mask} \begin{funcdesc}{umask}{mask}
@ -423,11 +436,14 @@ Set the current numeric umask and returns the previous umask.
\begin{funcdesc}{uname}{} \begin{funcdesc}{uname}{}
Return a 5-tuple containing information identifying the current Return a 5-tuple containing information identifying the current
operating system. The tuple contains 5 strings: operating system. The tuple contains 5 strings:
\code{(\var{sysname}, \var{nodename}, \var{release}, \var{version}, \var{machine})}. \code{(\var{sysname}, \var{nodename}, \var{release}, \var{version},
Some systems truncate the nodename to 8 \var{machine})}. Some systems truncate the nodename to 8
characters or to the leading component; a better way to get the characters or to the leading component; a better way to get the
hostname is \code{socket.gethostname()} or even hostname is \function{socket.gethostname()}%
\code{socket.gethostbyaddr(socket.gethostname())}. \index{gethostname()@\idxcode{gethostname()} (in module socket)}
or even
\code{socket.gethostbyaddr(socket.gethostname())}%
\index{gethostbyaddr()@\idxcode{gethostbyaddr()} (in module socket)}.
(Not on MS-DOS, nor on older \UNIX{} systems.) (Not on MS-DOS, nor on older \UNIX{} systems.)
\end{funcdesc} \end{funcdesc}
@ -452,10 +468,11 @@ byte is set if a core file was produced. (Not on MS-DOS.)
\begin{funcdesc}{waitpid}{pid\, options} \begin{funcdesc}{waitpid}{pid\, options}
Wait for completion of a child process given by proces id, and return Wait for completion of a child process given by proces id, and return
a tuple containing its pid and exit status indication (encoded as for a tuple containing its pid and exit status indication (encoded as for
\code{wait()}). The semantics of the call are affected by the value of \function{wait()}). The semantics of the call are affected by the
the integer options, which should be 0 for normal operation. (If the value of the integer \var{options}, which should be \code{0} for
system does not support \code{waitpid()}, this always raises normal operation. (If the system does not support
\code{posix.error}. Not on MS-DOS.) \function{waitpid()}, this always raises \exception{error}. Not on
MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{write}{fd\, str} \begin{funcdesc}{write}{fd\, str}
@ -463,16 +480,16 @@ Write the string \var{str} to file descriptor \var{fd}.
Return the number of bytes actually written. Return the number of bytes actually written.
Note: this function is intended for low-level I/O and must be applied Note: this function is intended for low-level I/O and must be applied
to a file descriptor as returned by \code{posix.open()} or to a file descriptor as returned by \function{open()} or
\code{posix.pipe()}. To write a ``file object'' returned by the \function{pipe()}. To write a ``file object'' returned by the
built-in function \code{open} or by \code{posix.popen} or built-in function \function{open()} or by \function{popen()} or
\code{posix.fdopen}, or \code{sys.stdout} or \code{sys.stderr}, use \function{fdopen()}, or \code{sys.stdout} or \code{sys.stderr}, use
its \code{write()} method. its \method{write()} method.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{WNOHANG} \begin{datadesc}{WNOHANG}
The option for \code{waitpid()} to avoid hanging if no child process The option for \function{waitpid()} to avoid hanging if no child
status is available immediately. process status is available immediately.
\end{datadesc} \end{datadesc}
@ -489,6 +506,6 @@ status is available immediately.
\dataline{O_CREAT} \dataline{O_CREAT}
\dataline{O_EXCL} \dataline{O_EXCL}
\dataline{O_TRUNC} \dataline{O_TRUNC}
Options for the \code{flag} argument to the \code{open()} function. Options for the \code{flag} argument to the \function{open()} function.
These can be bit-wise OR'd together. These can be bit-wise OR'd together.
\end{datadesc} \end{datadesc}

View file

@ -3,19 +3,19 @@
\bimodindex{posix} \bimodindex{posix}
This module provides access to operating system functionality that is This module provides access to operating system functionality that is
standardized by the C Standard and the \POSIX{} standard (a thinly disguised standardized by the \C{} Standard and the \POSIX{} standard (a thinly
\UNIX{} interface). disguised \UNIX{} interface).
\strong{Do not import this module directly.} Instead, import the \strong{Do not import this module directly.} Instead, import the
module \code{os}, which provides a \emph{portable} version of this module \module{os}, which provides a \emph{portable} version of this
interface. On \UNIX{}, the \code{os} module provides a superset of interface. On \UNIX{}, the \module{os} module provides a superset of
the \code{posix} interface. On non-\UNIX{} operating systems the the \module{posix} interface. On non-\UNIX{} operating systems the
\code{posix} module is not available, but a subset is always available \module{posix} module is not available, but a subset is always
through the \code{os} interface. Once \code{os} is imported, there is available through the \module{os} interface. Once \module{os} is
\emph{no} performance penalty in using it instead of imported, there is \emph{no} performance penalty in using it instead
\code{posix}. In addition, \code{os} provides some additional of \module{posix}. In addition, \module{os} provides some additional
functionality, such as automatically calling \code{putenv()} functionality, such as automatically calling \function{putenv()}
when an entry is \code{os.environ} is changed. when an entry in \code{os.environ} is changed.
\refstmodindex{os} \refstmodindex{os}
The descriptions below are very terse; refer to the corresponding The descriptions below are very terse; refer to the corresponding
@ -24,9 +24,9 @@ Arguments called \var{path} refer to a pathname given as a string.
Errors are reported as exceptions; the usual exceptions are given Errors are reported as exceptions; the usual exceptions are given
for type errors, while errors reported by the system calls raise for type errors, while errors reported by the system calls raise
\code{posix.error}, described below. \exception{error}, described below.
Module \code{posix} defines the following data items: Module \module{posix} defines the following data items:
\setindexsubitem{(data in module posix)} \setindexsubitem{(data in module posix)}
\begin{datadesc}{environ} \begin{datadesc}{environ}
@ -36,30 +36,40 @@ For example,
\code{posix.environ['HOME']} \code{posix.environ['HOME']}
is the pathname of your home directory, equivalent to is the pathname of your home directory, equivalent to
\code{getenv("HOME")} \code{getenv("HOME")}
in C. in \C{}.
Modifying this dictionary does not affect the string environment Modifying this dictionary does not affect the string environment
passed on by \code{execv()}, \code{popen()} or \code{system()}; if you passed on by \function{execv()}, \function{popen()} or
need to change the environment, pass \code{environ} to \code{execve()} \function{system()}; if you need to change the environment, pass
or add variable assignments and export statements to the command \code{environ} to \function{execve()} or add variable assignments and
string for \code{system()} or \code{popen()}. export statements to the command string for \function{system()} or
\function{popen()}.
\emph{However:} If you are using this module via the \code{os} module \emph{However:} If you are using this module via the \module{os}
(as you should -- see the introduction above), \code{environ} is a module (as you should -- see the introduction above), \code{environ}
a mapping object that behaves almost like a dictionary but invokes is a a mapping object that behaves almost like a dictionary but
\code{putenv()} automatically called whenever an item is changed. invokes \function{putenv()} automatically called whenever an item is
changed.
\end{datadesc} \end{datadesc}
\setindexsubitem{(exception in module posix)} \setindexsubitem{(exception in module posix)}
\begin{excdesc}{error} \begin{excdesc}{error}
This exception is raised when a \POSIX{} function returns a This exception is raised when a \POSIX{} function returns a
\POSIX{}-related error (e.g., not for illegal argument types). Its \POSIX{}-related error (e.g., not for illegal argument types). The
string value is \code{'posix.error'}. The accompanying value is a accompanying value is a pair containing the numeric error code from
pair containing the numeric error code from \code{errno} and the \cdata{errno} and the corresponding string, as would be printed by the
corresponding string, as would be printed by the C function \C{} function \cfunction{perror()}. See the module
\code{perror()}. \module{errno}\refbimodindex{errno}, which contains names for the
See the module \module{errno}\refbimodindex{errno}, which contains error codes defined by the underlying operating system.
names for the error codes defined by the underlying operating system.
When exceptions are classes, this exception carries two attributes,
\member{errno} and \member{strerror}. The first holds the value of
the \C{} \cdata{errno} variable, and the latter holds the
corresponding error message from \cfunction{strerror()}.
When exceptions are strings, the string for the exception is
\code{'os.error'}; this reflects the more portable access to the
exception through the \module{os} module.
\end{excdesc} \end{excdesc}
It defines the following functions and constants: It defines the following functions and constants:
@ -83,10 +93,10 @@ and \var{gid}.
Close file descriptor \var{fd}. Close file descriptor \var{fd}.
Note: this function is intended for low-level I/O and must be applied Note: this function is intended for low-level I/O and must be applied
to a file descriptor as returned by \code{posix.open()} or to a file descriptor as returned by \function{open()} or
\code{posix.pipe()}. To close a ``file object'' returned by the \function{pipe()}. To close a ``file object'' returned by the
built-in function \code{open} or by \code{posix.popen} or built-in function \function{open()} or by \function{popen()} or
\code{posix.fdopen}, use its \code{close()} method. \function{fdopen()}, use its \method{close()} method.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{dup}{fd} \begin{funcdesc}{dup}{fd}
@ -95,7 +105,7 @@ Return a duplicate of file descriptor \var{fd}.
\begin{funcdesc}{dup2}{fd\, fd2} \begin{funcdesc}{dup2}{fd\, fd2}
Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter
first if necessary. Return \code{None}. first if necessary.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{execv}{path\, args} \begin{funcdesc}{execv}{path\, args}
@ -120,24 +130,24 @@ handlers, flushing stdio buffers, etc.
(Not on MS-DOS.) (Not on MS-DOS.)
Note: the standard way to exit is \code{sys.exit(\var{n})}. Note: the standard way to exit is \code{sys.exit(\var{n})}.
\code{posix._exit()} should normally only be used in the child process \function{_exit()} should normally only be used in the child process
after a \code{fork()}. after a \function{fork()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fdopen}{fd\optional{\, mode\optional{\, bufsize}}} \begin{funcdesc}{fdopen}{fd\optional{\, mode\optional{\, bufsize}}}
Return an open file object connected to the file descriptor \var{fd}. Return an open file object connected to the file descriptor \var{fd}.
The \var{mode} and \var{bufsize} arguments have the same meaning as The \var{mode} and \var{bufsize} arguments have the same meaning as
the corresponding arguments to the built-in \code{open()} function. the corresponding arguments to the built-in \function{open()} function.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fork}{} \begin{funcdesc}{fork}{}
Fork a child process. Return 0 in the child, the child's process id Fork a child process. Return \code{0} in the child, the child's
in the parent. process id in the parent.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fstat}{fd} \begin{funcdesc}{fstat}{fd}
Return status for file descriptor \var{fd}, like \code{stat()}. Return status for file descriptor \var{fd}, like \function{stat()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{ftruncate}{fd\, length} \begin{funcdesc}{ftruncate}{fd\, length}
@ -203,61 +213,63 @@ directory.
\begin{funcdesc}{lseek}{fd\, pos\, how} \begin{funcdesc}{lseek}{fd\, pos\, how}
Set the current position of file descriptor \var{fd} to position Set the current position of file descriptor \var{fd} to position
\var{pos}, modified by \var{how}: 0 to set the position relative to \var{pos}, modified by \var{how}: \code{0} to set the position
the beginning of the file; 1 to set it relative to the current relative to the beginning of the file; \code{1} to set it relative to
position; 2 to set it relative to the end of the file. the current position; \code{2} to set it relative to the end of the
file.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{lstat}{path} \begin{funcdesc}{lstat}{path}
Like \code{stat()}, but do not follow symbolic links. (On systems Like \function{stat()}, but do not follow symbolic links. (On systems
without symbolic links, this is identical to \code{posix.stat()}.) without symbolic links, this is identical to \function{stat()}.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mkfifo}{path\optional{\, mode}} \begin{funcdesc}{mkfifo}{path\optional{\, mode}}
Create a FIFO (a \POSIX{} named pipe) named \var{path} with numeric mode Create a FIFO (a \POSIX{} named pipe) named \var{path} with numeric mode
\var{mode}. The default \var{mode} is 0666 (octal). The current \var{mode}. The default \var{mode} is \code{0666} (octal). The current
umask value is first masked out from the mode. umask value is first masked out from the mode.
(Not on MS-DOS.) (Not on MS-DOS.)
FIFOs are pipes that can be accessed like regular files. FIFOs exist FIFOs are pipes that can be accessed like regular files. FIFOs exist
until they are deleted (for example with \code{os.unlink}). until they are deleted (for example with \function{os.unlink()}).
Generally, FIFOs are used as rendez-vous between ``client'' and Generally, FIFOs are used as rendezvous between ``client'' and
``server'' type processes: the server opens the FIFO for reading, and ``server'' type processes: the server opens the FIFO for reading, and
the client opens it for writing. Note that \code{mkfifo()} doesn't the client opens it for writing. Note that \function{mkfifo()}
open the FIFO -- it just creates the rendez-vous point. doesn't open the FIFO --- it just creates the rendezvous point.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{mkdir}{path\optional{\, mode}} \begin{funcdesc}{mkdir}{path\optional{\, mode}}
Create a directory named \var{path} with numeric mode \var{mode}. Create a directory named \var{path} with numeric mode \var{mode}.
The default \var{mode} is 0777 (octal). On some systems, \var{mode} The default \var{mode} is \code{0777} (octal). On some systems,
is ignored. Where it is used, the current umask value is first \var{mode} is ignored. Where it is used, the current umask value is
masked out. first masked out.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{nice}{increment} \begin{funcdesc}{nice}{increment}
Add \var{incr} to the process' ``niceness''. Return the new niceness. Add \var{increment} to the process' ``niceness''. Return the new
(Not on MS-DOS.) niceness. (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{open}{file\, flags\optional{\, mode}} \begin{funcdesc}{open}{file\, flags\optional{\, mode}}
Open the file \var{file} and set various flags according to Open the file \var{file} and set various flags according to
\var{flags} and possibly its mode according to \var{mode}. \var{flags} and possibly its mode according to \var{mode}.
The default \var{mode} is 0777 (octal), and the current umask value is The default \var{mode} is \code{0777} (octal), and the current umask
first masked out. Return the file descriptor for the newly opened value is first masked out. Return the file descriptor for the newly
file. opened file.
For a description of the flag and mode values, see the \UNIX{} or C For a description of the flag and mode values, see the \UNIX{} or \C{}
run-time documentation; flag constants (like \code{O_RDONLY} and run-time documentation; flag constants (like \constant{O_RDONLY} and
\code{O_WRONLY}) are defined in this module too (see below). \constant{O_WRONLY}) are defined in this module too (see below).
Note: this function is intended for low-level I/O. For normal usage, Note: this function is intended for low-level I/O. For normal usage,
use the built-in function \code{open}, which returns a ``file object'' use the built-in function \function{open()}, which returns a ``file
with \code{read()} and \code{write()} methods (and many more). object'' with \method{read()} and \method{write()} methods (and many
more).
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{pipe}{} \begin{funcdesc}{pipe}{}
Create a pipe. Return a pair of file descriptors \code{(r, w)} Create a pipe. Return a pair of file descriptors \code{(\var{r},
usable for reading and writing, respectively. \var{w})} usable for reading and writing, respectively.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
@ -272,23 +284,23 @@ Open a pipe to or from \var{command}. The return value is an open
file object connected to the pipe, which can be read or written file object connected to the pipe, which can be read or written
depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}. depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}.
The \var{bufsize} argument has the same meaning as the corresponding The \var{bufsize} argument has the same meaning as the corresponding
argument to the built-in \code{open()} function. The exit status of argument to the built-in \function{open()} function. The exit status of
the command (encoded in the format specified for \code{wait()}) is the command (encoded in the format specified for \function{wait()}) is
available as the return value of the \code{close()} method of the file available as the return value of the \method{close()} method of the file
object. object.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{putenv}{varname\, value} \begin{funcdesc}{putenv}{varname\, value}
Set the environment variable named \var{varname} to the string \var{value}. Set the environment variable named \var{varname} to the string
Such changes to the environment affect \var{value}. Such changes to the environment affect subprocesses
subprocesses started with \code{os.system()}, \code{os.popen()} or started with \function{os.system()}, \function{os.popen()} or
\code{os.fork()} and \code{os.execv()}. (Not on all systems.) \function{os.fork()} and \function{os.execv()}. (Not on all systems.)
When \code{putenv()} is When \function{putenv()} is
supported, assignments to items in \code{os.environ} are automatically supported, assignments to items in \code{os.environ} are automatically
translated into corresponding calls to \code{os.putenv()}; however, translated into corresponding calls to \function{putenv()}; however,
calls to \code{os.putenv()} don't update \code{os.environ}, so it is calls to \function{putenv()} don't update \code{os.environ}, so it is
actually preferable to assign to items of \code{os.environ}. actually preferable to assign to items of \code{os.environ}.
\end{funcdesc} \end{funcdesc}
@ -301,22 +313,23 @@ Read at most \var{n} bytes from file descriptor \var{fd}.
Return a string containing the bytes read. Return a string containing the bytes read.
Note: this function is intended for low-level I/O and must be applied Note: this function is intended for low-level I/O and must be applied
to a file descriptor as returned by \code{posix.open()} or to a file descriptor as returned by \function{open()} or
\code{posix.pipe()}. To read a ``file object'' returned by the \function{pipe()}. To read a ``file object'' returned by the
built-in function \code{open} or by \code{posix.popen} or built-in function \function{open()} or by \function{popen()} or
\code{posix.fdopen}, or \code{sys.stdin}, use its \function{fdopen()}, or \code{sys.stdin}, use its
\code{read()} or \code{readline()} methods. \method{read()} or \method{readline()} methods.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{readlink}{path} \begin{funcdesc}{readlink}{path}
Return a string representing the path to which the symbolic link Return a string representing the path to which the symbolic link
points. (On systems without symbolic links, this always raises points. (On systems without symbolic links, this always raises
\code{posix.error}.) \exception{error}.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{remove}{path} \begin{funcdesc}{remove}{path}
Remove the file \var{path}. See \code{rmdir} below to remove a directory. Remove the file \var{path}. See \function{rmdir()} below to remove a
This is identical to the \code{unlink} function documented below. directory. This is identical to the \function{unlink()} function
documented below.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{rename}{src\, dst} \begin{funcdesc}{rename}{src\, dst}
@ -333,21 +346,21 @@ Set the current process' group id.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setpgrp}{} \begin{funcdesc}{setpgrp}{}
Calls the system call \code{setpgrp()} or \code{setpgrp(0, 0)} Calls the system call \cfunction{setpgrp()} or \cfunction{setpgrp(0,
depending on which version is implemented (if any). See the \UNIX{} 0)} depending on which version is implemented (if any). See the
manual for the semantics. \UNIX{} manual for the semantics.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setpgid}{pid\, pgrp} \begin{funcdesc}{setpgid}{pid\, pgrp}
Calls the system call \code{setpgid()}. See the \UNIX{} manual for Calls the system call \cfunction{setpgid()}. See the \UNIX{} manual
the semantics. for the semantics.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setsid}{} \begin{funcdesc}{setsid}{}
Calls the system call \code{setsid()}. See the \UNIX{} manual for the Calls the system call \cfunction{setsid()}. See the \UNIX{} manual
semantics. for the semantics.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
@ -357,9 +370,10 @@ Set the current process' user id.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{stat}{path} \begin{funcdesc}{stat}{path}
Perform a \emph{stat} system call on the given path. The return value Perform a \cfunction{stat()} system call on the given path. The
is a tuple of at least 10 integers giving the most important (and return value is a tuple of at least 10 integers giving the most
portable) members of the \emph{stat} structure, in the order important (and portable) members of the \emph{stat} structure, in the
order
\code{st_mode}, \code{st_mode},
\code{st_ino}, \code{st_ino},
\code{st_dev}, \code{st_dev},
@ -373,35 +387,34 @@ portable) members of the \emph{stat} structure, in the order
More items may be added at the end by some implementations. More items may be added at the end by some implementations.
(On MS-DOS, some items are filled with dummy values.) (On MS-DOS, some items are filled with dummy values.)
Note: The standard module \code{stat} defines functions and constants Note: The standard module \module{stat}\refstmodindex{stat} defines
that are useful for extracting information from a stat structure. functions and constants that are useful for extracting information
\refstmodindex{stat} from a stat structure.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{symlink}{src\, dst} \begin{funcdesc}{symlink}{src\, dst}
Create a symbolic link pointing to \var{src} named \var{dst}. (On Create a symbolic link pointing to \var{src} named \var{dst}. (On
systems without symbolic links, this always raises systems without symbolic links, this always raises \exception{error}.)
\code{posix.error}.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{system}{command} \begin{funcdesc}{system}{command}
Execute the command (a string) in a subshell. This is implemented by Execute the command (a string) in a subshell. This is implemented by
calling the Standard C function \code{system()}, and has the same calling the Standard \C{} function \cfunction{system()}, and has the
limitations. Changes to \code{posix.environ}, \code{sys.stdin} etc.\ are same limitations. Changes to \code{posix.environ}, \code{sys.stdin}
not reflected in the environment of the executed command. The return etc.\ are not reflected in the environment of the executed command.
value is the exit status of the process encoded in the format The return value is the exit status of the process encoded in the
specified for \code{wait()}. format specified for \function{wait()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{tcgetpgrp}{fd} \begin{funcdesc}{tcgetpgrp}{fd}
Return the process group associated with the terminal given by Return the process group associated with the terminal given by
\var{fd} (an open file descriptor as returned by \code{posix.open()}). \var{fd} (an open file descriptor as returned by \function{open()}).
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{tcsetpgrp}{fd\, pg} \begin{funcdesc}{tcsetpgrp}{fd\, pg}
Set the process group associated with the terminal given by Set the process group associated with the terminal given by
\var{fd} (an open file descriptor as returned by \code{posix.open()}) \var{fd} (an open file descriptor as returned by \function{open()})
to \var{pg}. to \var{pg}.
(Not on MS-DOS.) (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
@ -412,7 +425,7 @@ or other)
times, in seconds. The items are: user time, system time, children's times, in seconds. The items are: user time, system time, children's
user time, children's system time, and elapsed real time since a fixed user time, children's system time, and elapsed real time since a fixed
point in the past, in that order. See the \UNIX{} point in the past, in that order. See the \UNIX{}
manual page \emph{times}(2). (Not on MS-DOS.) manual page \manpage{times}{2}. (Not on MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{umask}{mask} \begin{funcdesc}{umask}{mask}
@ -423,11 +436,14 @@ Set the current numeric umask and returns the previous umask.
\begin{funcdesc}{uname}{} \begin{funcdesc}{uname}{}
Return a 5-tuple containing information identifying the current Return a 5-tuple containing information identifying the current
operating system. The tuple contains 5 strings: operating system. The tuple contains 5 strings:
\code{(\var{sysname}, \var{nodename}, \var{release}, \var{version}, \var{machine})}. \code{(\var{sysname}, \var{nodename}, \var{release}, \var{version},
Some systems truncate the nodename to 8 \var{machine})}. Some systems truncate the nodename to 8
characters or to the leading component; a better way to get the characters or to the leading component; a better way to get the
hostname is \code{socket.gethostname()} or even hostname is \function{socket.gethostname()}%
\code{socket.gethostbyaddr(socket.gethostname())}. \index{gethostname()@\idxcode{gethostname()} (in module socket)}
or even
\code{socket.gethostbyaddr(socket.gethostname())}%
\index{gethostbyaddr()@\idxcode{gethostbyaddr()} (in module socket)}.
(Not on MS-DOS, nor on older \UNIX{} systems.) (Not on MS-DOS, nor on older \UNIX{} systems.)
\end{funcdesc} \end{funcdesc}
@ -452,10 +468,11 @@ byte is set if a core file was produced. (Not on MS-DOS.)
\begin{funcdesc}{waitpid}{pid\, options} \begin{funcdesc}{waitpid}{pid\, options}
Wait for completion of a child process given by proces id, and return Wait for completion of a child process given by proces id, and return
a tuple containing its pid and exit status indication (encoded as for a tuple containing its pid and exit status indication (encoded as for
\code{wait()}). The semantics of the call are affected by the value of \function{wait()}). The semantics of the call are affected by the
the integer options, which should be 0 for normal operation. (If the value of the integer \var{options}, which should be \code{0} for
system does not support \code{waitpid()}, this always raises normal operation. (If the system does not support
\code{posix.error}. Not on MS-DOS.) \function{waitpid()}, this always raises \exception{error}. Not on
MS-DOS.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{write}{fd\, str} \begin{funcdesc}{write}{fd\, str}
@ -463,16 +480,16 @@ Write the string \var{str} to file descriptor \var{fd}.
Return the number of bytes actually written. Return the number of bytes actually written.
Note: this function is intended for low-level I/O and must be applied Note: this function is intended for low-level I/O and must be applied
to a file descriptor as returned by \code{posix.open()} or to a file descriptor as returned by \function{open()} or
\code{posix.pipe()}. To write a ``file object'' returned by the \function{pipe()}. To write a ``file object'' returned by the
built-in function \code{open} or by \code{posix.popen} or built-in function \function{open()} or by \function{popen()} or
\code{posix.fdopen}, or \code{sys.stdout} or \code{sys.stderr}, use \function{fdopen()}, or \code{sys.stdout} or \code{sys.stderr}, use
its \code{write()} method. its \method{write()} method.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{WNOHANG} \begin{datadesc}{WNOHANG}
The option for \code{waitpid()} to avoid hanging if no child process The option for \function{waitpid()} to avoid hanging if no child
status is available immediately. process status is available immediately.
\end{datadesc} \end{datadesc}
@ -489,6 +506,6 @@ status is available immediately.
\dataline{O_CREAT} \dataline{O_CREAT}
\dataline{O_EXCL} \dataline{O_EXCL}
\dataline{O_TRUNC} \dataline{O_TRUNC}
Options for the \code{flag} argument to the \code{open()} function. Options for the \code{flag} argument to the \function{open()} function.
These can be bit-wise OR'd together. These can be bit-wise OR'd together.
\end{datadesc} \end{datadesc}