1998-04-04 09:23:21 +02:00
|
|
|
\section{Built-in Module \module{posix}}
|
1998-07-23 19:59:49 +02:00
|
|
|
\declaremodule{builtin}{posix}
|
|
|
|
|
|
|
|
\modulesynopsis{The most common \POSIX{} system calls (normally used via module
|
|
|
|
\module{os}).}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
|
|
|
|
This module provides access to operating system functionality that is
|
1998-03-11 06:29:58 +01:00
|
|
|
standardized by the \C{} Standard and the \POSIX{} standard (a thinly
|
|
|
|
disguised \UNIX{} interface).
|
1995-03-17 17:07:09 +01:00
|
|
|
|
|
|
|
\strong{Do not import this module directly.} Instead, import the
|
1998-03-11 06:29:58 +01:00
|
|
|
module \module{os}, which provides a \emph{portable} version of this
|
|
|
|
interface. On \UNIX{}, the \module{os} module provides a superset of
|
|
|
|
the \module{posix} interface. On non-\UNIX{} operating systems the
|
|
|
|
\module{posix} module is not available, but a subset is always
|
|
|
|
available through the \module{os} interface. Once \module{os} is
|
|
|
|
imported, there is \emph{no} performance penalty in using it instead
|
|
|
|
of \module{posix}. In addition, \module{os} provides some additional
|
|
|
|
functionality, such as automatically calling \function{putenv()}
|
|
|
|
when an entry in \code{os.environ} is changed.
|
1997-12-15 22:42:51 +01:00
|
|
|
\refstmodindex{os}
|
1995-03-17 17:07:09 +01:00
|
|
|
|
1997-08-27 16:54:25 +02:00
|
|
|
The descriptions below are very terse; refer to the corresponding
|
1998-02-09 21:27:12 +01:00
|
|
|
\UNIX{} manual (or \POSIX{} documentation) entry for more information.
|
1997-08-27 16:54:25 +02:00
|
|
|
Arguments called \var{path} refer to a pathname given as a string.
|
1994-01-02 02:22:07 +01:00
|
|
|
|
1998-07-23 21:50:09 +02:00
|
|
|
Errors are reported as exceptions; the usual exceptions are given for
|
|
|
|
type errors, while errors reported by the system calls raise
|
|
|
|
\exception{error} (a synonym for the standard exception
|
|
|
|
\exception{OSError}), described
|
|
|
|
below.
|
1994-01-02 02:22:07 +01:00
|
|
|
|
1998-03-11 06:29:58 +01:00
|
|
|
Module \module{posix} defines the following data items:
|
1994-01-02 02:22:07 +01:00
|
|
|
|
|
|
|
\begin{datadesc}{environ}
|
|
|
|
A dictionary representing the string environment at the time
|
|
|
|
the interpreter was started.
|
|
|
|
For example,
|
|
|
|
\code{posix.environ['HOME']}
|
|
|
|
is the pathname of your home directory, equivalent to
|
|
|
|
\code{getenv("HOME")}
|
1998-03-11 06:29:58 +01:00
|
|
|
in \C{}.
|
1997-08-08 23:05:09 +02:00
|
|
|
|
1995-03-17 17:07:09 +01:00
|
|
|
Modifying this dictionary does not affect the string environment
|
1998-03-11 06:29:58 +01:00
|
|
|
passed on by \function{execv()}, \function{popen()} or
|
|
|
|
\function{system()}; if you need to change the environment, pass
|
|
|
|
\code{environ} to \function{execve()} or add variable assignments and
|
|
|
|
export statements to the command string for \function{system()} or
|
|
|
|
\function{popen()}.
|
|
|
|
|
|
|
|
\emph{However:} If you are using this module via the \module{os}
|
|
|
|
module (as you should -- see the introduction above), \code{environ}
|
|
|
|
is a a mapping object that behaves almost like a dictionary but
|
|
|
|
invokes \function{putenv()} automatically called whenever an item is
|
|
|
|
changed.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{excdesc}{error}
|
1998-02-09 21:27:12 +01:00
|
|
|
This exception is raised when a \POSIX{} function returns a
|
1998-03-11 06:29:58 +01:00
|
|
|
\POSIX{}-related error (e.g., not for illegal argument types). The
|
|
|
|
accompanying value is a pair containing the numeric error code from
|
|
|
|
\cdata{errno} and the corresponding string, as would be printed by the
|
|
|
|
\C{} function \cfunction{perror()}. See the module
|
|
|
|
\module{errno}\refbimodindex{errno}, which contains 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
|
1998-07-23 21:50:09 +02:00
|
|
|
corresponding error message from \cfunction{strerror()}. For
|
|
|
|
exceptions that involve a file system path (e.g. \code{chdir} or
|
|
|
|
\code{unlink}), the exception instance will contain a third attribute
|
|
|
|
\member{filename} which is the file name passed to the
|
|
|
|
function.
|
1998-03-11 06:29:58 +01:00
|
|
|
|
|
|
|
When exceptions are strings, the string for the exception is
|
1998-07-23 21:50:09 +02:00
|
|
|
\code{'OSError'}.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{excdesc}
|
|
|
|
|
1995-03-30 18:00:36 +02:00
|
|
|
It defines the following functions and constants:
|
1994-01-02 02:22:07 +01:00
|
|
|
|
|
|
|
\begin{funcdesc}{chdir}{path}
|
|
|
|
Change the current working directory to \var{path}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{chmod}{path, mode}
|
1994-01-02 02:22:07 +01:00
|
|
|
Change the mode of \var{path} to the numeric \var{mode}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{chown}{path, uid, gid}
|
1995-01-04 20:17:34 +01:00
|
|
|
Change the owner and group id of \var{path} to the numeric \var{uid}
|
|
|
|
and \var{gid}.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
\begin{funcdesc}{close}{fd}
|
|
|
|
Close file descriptor \var{fd}.
|
1995-01-12 13:38:22 +01:00
|
|
|
|
|
|
|
Note: this function is intended for low-level I/O and must be applied
|
1998-03-11 06:29:58 +01:00
|
|
|
to a file descriptor as returned by \function{open()} or
|
|
|
|
\function{pipe()}. To close a ``file object'' returned by the
|
|
|
|
built-in function \function{open()} or by \function{popen()} or
|
|
|
|
\function{fdopen()}, use its \method{close()} method.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{dup}{fd}
|
|
|
|
Return a duplicate of file descriptor \var{fd}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{dup2}{fd, fd2}
|
1994-01-02 02:22:07 +01:00
|
|
|
Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter
|
1998-03-11 06:29:58 +01:00
|
|
|
first if necessary.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{execv}{path, args}
|
1994-01-02 02:22:07 +01:00
|
|
|
Execute the executable \var{path} with argument list \var{args},
|
|
|
|
replacing the current process (i.e., the Python interpreter).
|
|
|
|
The argument list may be a tuple or list of strings.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{execve}{path, args, env}
|
1994-01-02 02:22:07 +01:00
|
|
|
Execute the executable \var{path} with argument list \var{args},
|
|
|
|
and environment \var{env},
|
|
|
|
replacing the current process (i.e., the Python interpreter).
|
|
|
|
The argument list may be a tuple or list of strings.
|
|
|
|
The environment must be a dictionary mapping strings to strings.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{_exit}{n}
|
|
|
|
Exit to the system with status \var{n}, without calling cleanup
|
|
|
|
handlers, flushing stdio buffers, etc.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
|
|
|
|
Note: the standard way to exit is \code{sys.exit(\var{n})}.
|
1998-03-11 06:29:58 +01:00
|
|
|
\function{_exit()} should normally only be used in the child process
|
|
|
|
after a \function{fork()}.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{fdopen}{fd\optional{, mode\optional{, bufsize}}}
|
1995-01-12 13:38:22 +01:00
|
|
|
Return an open file object connected to the file descriptor \var{fd}.
|
|
|
|
The \var{mode} and \var{bufsize} arguments have the same meaning as
|
1998-03-11 06:29:58 +01:00
|
|
|
the corresponding arguments to the built-in \function{open()} function.
|
1994-02-15 16:59:23 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
\begin{funcdesc}{fork}{}
|
1998-03-11 06:29:58 +01:00
|
|
|
Fork a child process. Return \code{0} in the child, the child's
|
|
|
|
process id in the parent.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{fstat}{fd}
|
1998-03-11 06:29:58 +01:00
|
|
|
Return status for file descriptor \var{fd}, like \function{stat()}.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{ftruncate}{fd, length}
|
1997-06-02 19:28:51 +02:00
|
|
|
Truncate the file corresponding to file descriptor \var{fd},
|
|
|
|
so that it is at most \var{length} bytes in size.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
\begin{funcdesc}{getcwd}{}
|
|
|
|
Return a string representing the current working directory.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getegid}{}
|
1997-12-30 21:38:16 +01:00
|
|
|
Return the current process' effective group id.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{geteuid}{}
|
1997-12-30 21:38:16 +01:00
|
|
|
Return the current process' effective user id.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getgid}{}
|
1997-12-30 21:38:16 +01:00
|
|
|
Return the current process' group id.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1996-06-26 21:22:46 +02:00
|
|
|
\begin{funcdesc}{getpgrp}{}
|
|
|
|
Return the current process group id.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
\begin{funcdesc}{getpid}{}
|
|
|
|
Return the current process id.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getppid}{}
|
|
|
|
Return the parent's process id.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getuid}{}
|
1997-12-30 21:38:16 +01:00
|
|
|
Return the current process' user id.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{kill}{pid, sig}
|
1994-01-02 02:22:07 +01:00
|
|
|
Kill the process \var{pid} with signal \var{sig}.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{link}{src, dst}
|
1994-01-02 02:22:07 +01:00
|
|
|
Create a hard link pointing to \var{src} named \var{dst}.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{listdir}{path}
|
|
|
|
Return a list containing the names of the entries in the directory.
|
1996-02-13 00:16:08 +01:00
|
|
|
The list is in arbitrary order. It does not include the special
|
|
|
|
entries \code{'.'} and \code{'..'} even if they are present in the
|
|
|
|
directory.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{lseek}{fd, pos, how}
|
1994-01-02 02:22:07 +01:00
|
|
|
Set the current position of file descriptor \var{fd} to position
|
1998-03-11 06:29:58 +01:00
|
|
|
\var{pos}, modified by \var{how}: \code{0} to set the position
|
|
|
|
relative to the beginning of the file; \code{1} to set it relative to
|
|
|
|
the current position; \code{2} to set it relative to the end of the
|
|
|
|
file.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{lstat}{path}
|
1998-03-11 06:29:58 +01:00
|
|
|
Like \function{stat()}, but do not follow symbolic links. (On systems
|
|
|
|
without symbolic links, this is identical to \function{stat()}.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{mkfifo}{path\optional{, mode}}
|
1998-02-09 21:27:12 +01:00
|
|
|
Create a FIFO (a \POSIX{} named pipe) named \var{path} with numeric mode
|
1998-03-11 06:29:58 +01:00
|
|
|
\var{mode}. The default \var{mode} is \code{0666} (octal). The current
|
1996-06-26 21:22:46 +02:00
|
|
|
umask value is first masked out from the mode.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
|
|
|
|
FIFOs are pipes that can be accessed like regular files. FIFOs exist
|
1998-03-11 06:29:58 +01:00
|
|
|
until they are deleted (for example with \function{os.unlink()}).
|
|
|
|
Generally, FIFOs are used as rendezvous between ``client'' and
|
1996-06-26 21:22:46 +02:00
|
|
|
``server'' type processes: the server opens the FIFO for reading, and
|
1998-03-11 06:29:58 +01:00
|
|
|
the client opens it for writing. Note that \function{mkfifo()}
|
|
|
|
doesn't open the FIFO --- it just creates the rendezvous point.
|
1996-06-26 21:22:46 +02:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{mkdir}{path\optional{, mode}}
|
1994-01-02 02:22:07 +01:00
|
|
|
Create a directory named \var{path} with numeric mode \var{mode}.
|
1998-03-11 06:29:58 +01:00
|
|
|
The default \var{mode} is \code{0777} (octal). On some systems,
|
|
|
|
\var{mode} is ignored. Where it is used, the current umask value is
|
|
|
|
first masked out.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{nice}{increment}
|
1998-03-11 06:29:58 +01:00
|
|
|
Add \var{increment} to the process' ``niceness''. Return the new
|
|
|
|
niceness. (Not on MS-DOS.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{open}{file, flags\optional{, mode}}
|
1994-01-02 02:22:07 +01:00
|
|
|
Open the file \var{file} and set various flags according to
|
|
|
|
\var{flags} and possibly its mode according to \var{mode}.
|
1998-03-11 06:29:58 +01:00
|
|
|
The default \var{mode} is \code{0777} (octal), and the current umask
|
|
|
|
value is first masked out. Return the file descriptor for the newly
|
|
|
|
opened file.
|
1995-01-12 13:38:22 +01:00
|
|
|
|
1998-03-11 06:29:58 +01:00
|
|
|
For a description of the flag and mode values, see the \UNIX{} or \C{}
|
|
|
|
run-time documentation; flag constants (like \constant{O_RDONLY} and
|
|
|
|
\constant{O_WRONLY}) are defined in this module too (see below).
|
1997-08-08 23:05:09 +02:00
|
|
|
|
1995-01-12 13:38:22 +01:00
|
|
|
Note: this function is intended for low-level I/O. For normal usage,
|
1998-03-11 06:29:58 +01:00
|
|
|
use the built-in function \function{open()}, which returns a ``file
|
|
|
|
object'' with \method{read()} and \method{write()} methods (and many
|
|
|
|
more).
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{pipe}{}
|
1998-03-11 06:29:58 +01:00
|
|
|
Create a pipe. Return a pair of file descriptors \code{(\var{r},
|
|
|
|
\var{w})} usable for reading and writing, respectively.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1996-07-21 04:21:49 +02:00
|
|
|
\begin{funcdesc}{plock}{op}
|
|
|
|
Lock program segments into memory. The value of \var{op}
|
|
|
|
(defined in \code{<sys/lock.h>}) determines which segments are locked.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{popen}{command\optional{, mode\optional{, bufsize}}}
|
1994-01-02 02:22:07 +01:00
|
|
|
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
|
1995-01-12 13:38:22 +01:00
|
|
|
depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}.
|
|
|
|
The \var{bufsize} argument has the same meaning as the corresponding
|
1998-03-11 06:29:58 +01:00
|
|
|
argument to the built-in \function{open()} function. The exit status of
|
|
|
|
the command (encoded in the format specified for \function{wait()}) is
|
|
|
|
available as the return value of the \method{close()} method of the file
|
1997-05-09 04:22:59 +02:00
|
|
|
object.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{putenv}{varname, value}
|
1998-03-16 06:21:08 +01:00
|
|
|
\index{environment variables!setting}
|
1998-03-11 06:29:58 +01:00
|
|
|
Set the environment variable named \var{varname} to the string
|
|
|
|
\var{value}. Such changes to the environment affect subprocesses
|
|
|
|
started with \function{os.system()}, \function{os.popen()} or
|
|
|
|
\function{os.fork()} and \function{os.execv()}. (Not on all systems.)
|
1997-06-02 19:28:51 +02:00
|
|
|
|
1998-03-11 06:29:58 +01:00
|
|
|
When \function{putenv()} is
|
1997-06-02 19:28:51 +02:00
|
|
|
supported, assignments to items in \code{os.environ} are automatically
|
1998-03-11 06:29:58 +01:00
|
|
|
translated into corresponding calls to \function{putenv()}; however,
|
|
|
|
calls to \function{putenv()} don't update \code{os.environ}, so it is
|
1997-06-02 19:28:51 +02:00
|
|
|
actually preferable to assign to items of \code{os.environ}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1997-10-05 20:54:52 +02:00
|
|
|
\begin{funcdesc}{strerror}{code}
|
|
|
|
Return the error message corresponding to the error code in \var{code}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{read}{fd, n}
|
1994-01-02 02:22:07 +01:00
|
|
|
Read at most \var{n} bytes from file descriptor \var{fd}.
|
|
|
|
Return a string containing the bytes read.
|
1995-01-12 13:38:22 +01:00
|
|
|
|
|
|
|
Note: this function is intended for low-level I/O and must be applied
|
1998-03-11 06:29:58 +01:00
|
|
|
to a file descriptor as returned by \function{open()} or
|
|
|
|
\function{pipe()}. To read a ``file object'' returned by the
|
|
|
|
built-in function \function{open()} or by \function{popen()} or
|
|
|
|
\function{fdopen()}, or \code{sys.stdin}, use its
|
|
|
|
\method{read()} or \method{readline()} methods.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{readlink}{path}
|
|
|
|
Return a string representing the path to which the symbolic link
|
|
|
|
points. (On systems without symbolic links, this always raises
|
1998-03-11 06:29:58 +01:00
|
|
|
\exception{error}.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1996-02-13 00:16:08 +01:00
|
|
|
\begin{funcdesc}{remove}{path}
|
1998-03-11 06:29:58 +01:00
|
|
|
Remove the file \var{path}. See \function{rmdir()} below to remove a
|
|
|
|
directory. This is identical to the \function{unlink()} function
|
|
|
|
documented below.
|
1996-02-13 00:16:08 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{rename}{src, dst}
|
1994-01-02 02:22:07 +01:00
|
|
|
Rename the file or directory \var{src} to \var{dst}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{rmdir}{path}
|
|
|
|
Remove the directory \var{path}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{setgid}{gid}
|
1997-12-30 21:38:16 +01:00
|
|
|
Set the current process' group id.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1996-06-26 21:22:46 +02:00
|
|
|
\begin{funcdesc}{setpgrp}{}
|
1998-03-11 06:29:58 +01:00
|
|
|
Calls the system call \cfunction{setpgrp()} or \cfunction{setpgrp(0,
|
|
|
|
0)} depending on which version is implemented (if any). See the
|
|
|
|
\UNIX{} manual for the semantics.
|
1996-06-26 21:22:46 +02:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{setpgid}{pid, pgrp}
|
1998-03-11 06:29:58 +01:00
|
|
|
Calls the system call \cfunction{setpgid()}. See the \UNIX{} manual
|
|
|
|
for the semantics.
|
1996-06-26 21:22:46 +02:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{setsid}{}
|
1998-03-11 06:29:58 +01:00
|
|
|
Calls the system call \cfunction{setsid()}. See the \UNIX{} manual
|
|
|
|
for the semantics.
|
1996-06-26 21:22:46 +02:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
\begin{funcdesc}{setuid}{uid}
|
1997-12-30 21:38:16 +01:00
|
|
|
Set the current process' user id.
|
1994-01-02 02:22:07 +01:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{stat}{path}
|
1998-03-11 06:29:58 +01:00
|
|
|
Perform a \cfunction{stat()} system call on the given path. The
|
|
|
|
return value is a tuple of at least 10 integers giving the most
|
|
|
|
important (and portable) members of the \emph{stat} structure, in the
|
|
|
|
order
|
1994-01-02 02:22:07 +01:00
|
|
|
\code{st_mode},
|
|
|
|
\code{st_ino},
|
|
|
|
\code{st_dev},
|
|
|
|
\code{st_nlink},
|
|
|
|
\code{st_uid},
|
|
|
|
\code{st_gid},
|
|
|
|
\code{st_size},
|
|
|
|
\code{st_atime},
|
|
|
|
\code{st_mtime},
|
|
|
|
\code{st_ctime}.
|
|
|
|
More items may be added at the end by some implementations.
|
|
|
|
(On MS-DOS, some items are filled with dummy values.)
|
|
|
|
|
1998-03-11 06:29:58 +01:00
|
|
|
Note: The standard module \module{stat}\refstmodindex{stat} defines
|
|
|
|
functions and constants that are useful for extracting information
|
|
|
|
from a stat structure.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{symlink}{src, dst}
|
1994-01-02 02:22:07 +01:00
|
|
|
Create a symbolic link pointing to \var{src} named \var{dst}. (On
|
1998-03-11 06:29:58 +01:00
|
|
|
systems without symbolic links, this always raises \exception{error}.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{system}{command}
|
|
|
|
Execute the command (a string) in a subshell. This is implemented by
|
1998-03-11 06:29:58 +01:00
|
|
|
calling the Standard \C{} function \cfunction{system()}, and has the
|
|
|
|
same limitations. Changes to \code{posix.environ}, \code{sys.stdin}
|
|
|
|
etc.\ are not reflected in the environment of the executed command.
|
|
|
|
The return value is the exit status of the process encoded in the
|
|
|
|
format specified for \function{wait()}.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1996-06-26 21:22:46 +02:00
|
|
|
\begin{funcdesc}{tcgetpgrp}{fd}
|
|
|
|
Return the process group associated with the terminal given by
|
1998-03-11 06:29:58 +01:00
|
|
|
\var{fd} (an open file descriptor as returned by \function{open()}).
|
1996-06-26 21:22:46 +02:00
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{tcsetpgrp}{fd, pg}
|
1996-06-26 21:22:46 +02:00
|
|
|
Set the process group associated with the terminal given by
|
1998-03-11 06:29:58 +01:00
|
|
|
\var{fd} (an open file descriptor as returned by \function{open()})
|
1996-06-26 21:22:46 +02:00
|
|
|
to \var{pg}.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-02 02:22:07 +01:00
|
|
|
\begin{funcdesc}{times}{}
|
1995-09-13 19:36:35 +02:00
|
|
|
Return a 5-tuple of floating point numbers indicating accumulated (CPU
|
|
|
|
or other)
|
1994-01-02 02:22:07 +01:00
|
|
|
times, in seconds. The items are: user time, system time, children's
|
1995-09-13 19:36:35 +02:00
|
|
|
user time, children's system time, and elapsed real time since a fixed
|
|
|
|
point in the past, in that order. See the \UNIX{}
|
1998-03-11 06:29:58 +01:00
|
|
|
manual page \manpage{times}{2}. (Not on MS-DOS.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{umask}{mask}
|
|
|
|
Set the current numeric umask and returns the previous umask.
|
|
|
|
(Not on MS-DOS.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{uname}{}
|
|
|
|
Return a 5-tuple containing information identifying the current
|
|
|
|
operating system. The tuple contains 5 strings:
|
1998-03-11 06:29:58 +01:00
|
|
|
\code{(\var{sysname}, \var{nodename}, \var{release}, \var{version},
|
|
|
|
\var{machine})}. Some systems truncate the nodename to 8
|
1995-03-13 11:03:32 +01:00
|
|
|
characters or to the leading component; a better way to get the
|
1998-03-11 06:29:58 +01:00
|
|
|
hostname is \function{socket.gethostname()}%
|
1998-03-12 07:44:58 +01:00
|
|
|
\withsubitem{(in module socket)}{\ttindex{gethostname()}}
|
1998-03-11 06:29:58 +01:00
|
|
|
or even
|
|
|
|
\code{socket.gethostbyaddr(socket.gethostname())}%
|
1998-03-12 07:44:58 +01:00
|
|
|
\withsubitem{(in module socket)}{\ttindex{gethostbyaddr()}}.
|
1997-12-30 21:38:16 +01:00
|
|
|
(Not on MS-DOS, nor on older \UNIX{} systems.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{unlink}{path}
|
1996-02-13 00:16:08 +01:00
|
|
|
Remove the file \var{path}. This is the same function as \code{remove};
|
|
|
|
the \code{unlink} name is its traditional \UNIX{} name.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{utime}{path, {\rm (}atime, mtime{\rm )}}
|
1994-01-02 02:22:07 +01:00
|
|
|
Set the access and modified time of the file to the given values.
|
|
|
|
(The second argument is a tuple of two items.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{wait}{}
|
|
|
|
Wait for completion of a child process, and return a tuple containing
|
1997-05-09 04:22:59 +02:00
|
|
|
its pid and exit status indication: a 16-bit number, whose low byte is
|
|
|
|
the signal number that killed the process, and whose high byte is the
|
|
|
|
exit status (if the signal number is zero); the high bit of the low
|
|
|
|
byte is set if a core file was produced. (Not on MS-DOS.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{waitpid}{pid, options}
|
1994-01-02 02:22:07 +01:00
|
|
|
Wait for completion of a child process given by proces id, and return
|
1997-05-09 04:22:59 +02:00
|
|
|
a tuple containing its pid and exit status indication (encoded as for
|
1998-03-11 06:29:58 +01:00
|
|
|
\function{wait()}). The semantics of the call are affected by the
|
|
|
|
value of the integer \var{options}, which should be \code{0} for
|
|
|
|
normal operation. (If the system does not support
|
|
|
|
\function{waitpid()}, this always raises \exception{error}. Not on
|
|
|
|
MS-DOS.)
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 07:33:25 +01:00
|
|
|
\begin{funcdesc}{write}{fd, str}
|
1994-01-02 02:22:07 +01:00
|
|
|
Write the string \var{str} to file descriptor \var{fd}.
|
|
|
|
Return the number of bytes actually written.
|
1995-01-12 13:38:22 +01:00
|
|
|
|
|
|
|
Note: this function is intended for low-level I/O and must be applied
|
1998-03-11 06:29:58 +01:00
|
|
|
to a file descriptor as returned by \function{open()} or
|
|
|
|
\function{pipe()}. To write a ``file object'' returned by the
|
|
|
|
built-in function \function{open()} or by \function{popen()} or
|
|
|
|
\function{fdopen()}, or \code{sys.stdout} or \code{sys.stderr}, use
|
|
|
|
its \method{write()} method.
|
1994-01-02 02:22:07 +01:00
|
|
|
\end{funcdesc}
|
1995-03-30 18:00:36 +02:00
|
|
|
|
|
|
|
\begin{datadesc}{WNOHANG}
|
1998-03-11 06:29:58 +01:00
|
|
|
The option for \function{waitpid()} to avoid hanging if no child
|
|
|
|
process status is available immediately.
|
1995-03-30 18:00:36 +02:00
|
|
|
\end{datadesc}
|
1996-12-20 00:50:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
\begin{datadesc}{O_RDONLY}
|
1998-02-13 22:55:21 +01:00
|
|
|
\dataline{O_WRONLY}
|
|
|
|
\dataline{O_RDWR}
|
|
|
|
\dataline{O_NDELAY}
|
|
|
|
\dataline{O_NONBLOCK}
|
|
|
|
\dataline{O_APPEND}
|
|
|
|
\dataline{O_DSYNC}
|
|
|
|
\dataline{O_RSYNC}
|
|
|
|
\dataline{O_SYNC}
|
|
|
|
\dataline{O_NOCTTY}
|
|
|
|
\dataline{O_CREAT}
|
|
|
|
\dataline{O_EXCL}
|
|
|
|
\dataline{O_TRUNC}
|
1998-03-11 06:29:58 +01:00
|
|
|
Options for the \code{flag} argument to the \function{open()} function.
|
1996-12-20 00:50:34 +01:00
|
|
|
These can be bit-wise OR'd together.
|
|
|
|
\end{datadesc}
|