source: vendor/python/2.5/Doc/lib/libposix.tex

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 4.0 KB
Line 
1\section{\module{posix} ---
2 The most common \POSIX{} system calls}
3
4\declaremodule{builtin}{posix}
5 \platform{Unix}
6\modulesynopsis{The most common \POSIX\ system calls (normally used
7 via module \refmodule{os}).}
8
9
10This module provides access to operating system functionality that is
11standardized by the C Standard and the \POSIX{} standard (a thinly
12disguised \UNIX{} interface).
13
14\strong{Do not import this module directly.} Instead, import the
15module \refmodule{os}, which provides a \emph{portable} version of this
16interface. On \UNIX, the \refmodule{os} module provides a superset of
17the \module{posix} interface. On non-\UNIX{} operating systems the
18\module{posix} module is not available, but a subset is always
19available through the \refmodule{os} interface. Once \refmodule{os} is
20imported, there is \emph{no} performance penalty in using it instead
21of \module{posix}. In addition, \refmodule{os}\refstmodindex{os}
22provides some additional functionality, such as automatically calling
23\function{putenv()} when an entry in \code{os.environ} is changed.
24
25The descriptions below are very terse; refer to the corresponding
26\UNIX{} manual (or \POSIX{} documentation) entry for more information.
27Arguments called \var{path} refer to a pathname given as a string.
28
29Errors are reported as exceptions; the usual exceptions are given for
30type errors, while errors reported by the system calls raise
31\exception{error} (a synonym for the standard exception
32\exception{OSError}), described below.
33
34
35\subsection{Large File Support \label{posix-large-files}}
36\sectionauthor{Steve Clift}{clift@mail.anacapa.net}
37\index{large files}
38\index{file!large files}
39
40
41Several operating systems (including AIX, HPUX, Irix and Solaris)
42provide support for files that are larger than 2 Gb from a C
43programming model where \ctype{int} and \ctype{long} are 32-bit
44values. This is typically accomplished by defining the relevant size
45and offset types as 64-bit values. Such files are sometimes referred
46to as \dfn{large files}.
47
48Large file support is enabled in Python when the size of an
49\ctype{off_t} is larger than a \ctype{long} and the \ctype{long long}
50type is available and is at least as large as an \ctype{off_t}. Python
51longs are then used to represent file sizes, offsets and other values
52that can exceed the range of a Python int. It may be necessary to
53configure and compile Python with certain compiler flags to enable
54this mode. For example, it is enabled by default with recent versions
55of Irix, but with Solaris 2.6 and 2.7 you need to do something like:
56
57\begin{verbatim}
58CFLAGS="`getconf LFS_CFLAGS`" OPT="-g -O2 $CFLAGS" \
59 ./configure
60\end{verbatim} % $ <-- bow to font-lock
61
62On large-file-capable Linux systems, this might work:
63
64\begin{verbatim}
65CFLAGS='-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' OPT="-g -O2 $CFLAGS" \
66 ./configure
67\end{verbatim} % $ <-- bow to font-lock
68
69
70\subsection{Module Contents \label{posix-contents}}
71
72
73Module \module{posix} defines the following data item:
74
75\begin{datadesc}{environ}
76A dictionary representing the string environment at the time the
77interpreter was started. For example, \code{environ['HOME']} is the
78pathname of your home directory, equivalent to
79\code{getenv("HOME")} in C.
80
81Modifying this dictionary does not affect the string environment
82passed on by \function{execv()}, \function{popen()} or
83\function{system()}; if you need to change the environment, pass
84\code{environ} to \function{execve()} or add variable assignments and
85export statements to the command string for \function{system()} or
86\function{popen()}.
87
88\note{The \refmodule{os} module provides an alternate
89implementation of \code{environ} which updates the environment on
90modification. Note also that updating \code{os.environ} will render
91this dictionary obsolete. Use of the \refmodule{os} module version of
92this is recommended over direct access to the \module{posix} module.}
93\end{datadesc}
94
95Additional contents of this module should only be accessed via the
96\refmodule{os} module; refer to the documentation for that module for
97further information.
Note: See TracBrowser for help on using the repository browser.