1998-08-10 16:42:37 -03:00
|
|
|
\section{\module{posix} ---
|
|
|
|
The most common \POSIX{} system calls.}
|
1998-07-23 14:59:49 -03:00
|
|
|
\declaremodule{builtin}{posix}
|
|
|
|
|
1999-01-11 14:36:23 -04:00
|
|
|
\modulesynopsis{The most common \POSIX{} system calls (normally used
|
|
|
|
via module \module{os}).}
|
1998-07-23 14:59:49 -03:00
|
|
|
|
1994-01-01 21:22:07 -04:00
|
|
|
|
|
|
|
This module provides access to operating system functionality that is
|
1999-02-01 16:23:02 -04:00
|
|
|
standardized by the C Standard and the \POSIX{} standard (a thinly
|
1998-03-11 01:29:58 -04:00
|
|
|
disguised \UNIX{} interface).
|
1995-03-17 12:07:09 -04:00
|
|
|
|
|
|
|
\strong{Do not import this module directly.} Instead, import the
|
1999-02-02 15:02:35 -04:00
|
|
|
module \refmodule{os}, which provides a \emph{portable} version of this
|
1998-03-11 01:29:58 -04:00
|
|
|
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
|
1999-01-11 14:36:23 -04:00
|
|
|
of \module{posix}. In addition, \module{os}\refstmodindex{os}
|
|
|
|
provides some additional functionality, such as automatically calling
|
|
|
|
\function{putenv()} when an entry in \code{os.environ} is changed.
|
1995-03-17 12:07:09 -04:00
|
|
|
|
1997-08-27 11:54:25 -03:00
|
|
|
The descriptions below are very terse; refer to the corresponding
|
1998-02-09 16:27:12 -04:00
|
|
|
\UNIX{} manual (or \POSIX{} documentation) entry for more information.
|
1997-08-27 11:54:25 -03:00
|
|
|
Arguments called \var{path} refer to a pathname given as a string.
|
1994-01-01 21:22:07 -04:00
|
|
|
|
1998-07-23 16:50:09 -03: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
|
1999-01-11 14:36:23 -04:00
|
|
|
\exception{OSError}), described below.
|
|
|
|
|
1999-02-02 15:02:35 -04:00
|
|
|
|
1999-01-11 14:36:23 -04:00
|
|
|
\subsection{Large File Support \label{posix-large-files}}
|
1999-02-02 15:02:35 -04:00
|
|
|
\sectionauthor{Steve Clift}{clift@mail.anacapa.net}
|
1999-01-11 14:36:23 -04:00
|
|
|
\index{large files}
|
|
|
|
\index{file!large files}
|
|
|
|
|
|
|
|
|
|
|
|
Several operating systems (including AIX, HPUX, Irix and Solaris)
|
1999-02-01 16:23:02 -04:00
|
|
|
provide support for files that are larger than 2 Gb from a C
|
1999-01-11 14:36:23 -04:00
|
|
|
programming model where \ctype{int} and \ctype{long} are 32-bit
|
|
|
|
values. This is typically accomplished by defining the relevant size
|
|
|
|
and offset types as 64-bit values. Such files are sometimes referred
|
|
|
|
to as \dfn{large files}.
|
|
|
|
|
|
|
|
Large file support is enabled in Python when the size of an
|
|
|
|
\ctype{off_t} is larger than a \ctype{long} and the \ctype{long long}
|
|
|
|
type is available and is at least as large as an \ctype{off_t}. Python
|
|
|
|
longs are then used to represent file sizes, offsets and other values
|
|
|
|
that can exceed the range of a Python int. It may be necessary to
|
|
|
|
configure and compile Python with certain compiler flags to enable
|
|
|
|
this mode. For example, it is enabled by default with recent versions
|
|
|
|
of Irix, but with Solaris 2.6 and 2.7 you need to do something like:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" OPT="-g -O2 $CFLAGS" \
|
|
|
|
configure
|
|
|
|
\end{verbatim} % $ <-- bow to font-lock
|
|
|
|
|
|
|
|
|
1999-02-02 15:02:35 -04:00
|
|
|
\subsection{Module Contents \label{posix-contents}}
|
|
|
|
|
1994-01-01 21:22:07 -04:00
|
|
|
|
1999-02-01 16:23:02 -04:00
|
|
|
Module \module{posix} defines the following data item:
|
1994-01-01 21:22:07 -04:00
|
|
|
|
|
|
|
\begin{datadesc}{environ}
|
1999-02-01 16:23:02 -04:00
|
|
|
A dictionary representing the string environment at the time the
|
|
|
|
interpreter was started. For example, \code{environ['HOME']} is the
|
|
|
|
pathname of your home directory, equivalent to \code{getenv("HOME")}
|
|
|
|
in C.
|
1997-08-08 18:05:09 -03:00
|
|
|
|
1995-03-17 12:07:09 -04:00
|
|
|
Modifying this dictionary does not affect the string environment
|
1998-03-11 01:29:58 -04: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()}.
|
|
|
|
|
1999-02-02 15:02:35 -04:00
|
|
|
\strong{Note:} The \refmodule{os} module provides an alternate
|
1999-02-01 16:23:02 -04:00
|
|
|
implementation of \code{environ} which updates the environment on
|
|
|
|
modification. Note also that updating \code{os.environ} will render
|
1999-02-02 15:02:35 -04:00
|
|
|
this dictionary obsolete. Use of the \refmodule{os} for this is
|
1999-02-01 16:23:02 -04:00
|
|
|
recommended over direct access to the \module{posix} module.
|
1994-01-01 21:22:07 -04:00
|
|
|
\end{datadesc}
|
|
|
|
|
1999-02-01 16:23:02 -04:00
|
|
|
Additional contents of this module should only be accessed via the
|
1999-02-02 15:02:35 -04:00
|
|
|
\refmodule{os} module; refer to the documentation for that module for
|
1999-02-01 16:23:02 -04:00
|
|
|
further information.
|