Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
328e3775
Commit
328e3775
authored
May 06, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure that availability information is on its own line at the end of the function docs
parent
7aaef849
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
341 additions
and
133 deletions
+341
-133
Doc/library/os.rst
Doc/library/os.rst
+341
-133
No files found.
Doc/library/os.rst
View file @
328e3775
...
@@ -32,6 +32,9 @@ Notes on the availability of these functions:
...
@@ -32,6 +32,9 @@ Notes on the availability of these functions:
* If not separately noted, all functions that claim "Availability: Unix" are
* If not separately noted, all functions that claim "Availability: Unix" are
supported on Mac OS X, which builds on a Unix core.
supported on Mac OS X, which builds on a Unix core.
.. Availability notes get their own line and occur at the end of the function
.. documentation.
.. note::
.. note::
All functions in this module raise :exc:`OSError` in the case of invalid or
All functions in this module raise :exc:`OSError` in the case of invalid or
...
@@ -111,33 +114,40 @@ process and user.
...
@@ -111,33 +114,40 @@ process and user.
.. function:: ctermid()
.. function:: ctermid()
Return the filename corresponding to the controlling terminal of the process.
Return the filename corresponding to the controlling terminal of the process.
Availability: Unix.
Availability: Unix.
.. function:: getegid()
.. function:: getegid()
Return the effective group id of the current process. This corresponds to the
Return the effective group id of the current process. This corresponds to the
"set id" bit on the file being executed in the current process. Availability:
"set id" bit on the file being executed in the current process.
Unix.
Availability: Unix.
.. function:: geteuid()
.. function:: geteuid()
.. index:: single: user; effective id
.. index:: single: user; effective id
Return the current process's effective user id. Availability: Unix.
Return the current process's effective user id.
Availability: Unix.
.. function:: getgid()
.. function:: getgid()
.. index:: single: process; group
.. index:: single: process; group
Return the real group id of the current process. Availability: Unix.
Return the real group id of the current process.
Availability: Unix.
.. function:: getgroups()
.. function:: getgroups()
Return list of supplemental group ids associated with the current process.
Return list of supplemental group ids associated with the current process.
Availability: Unix.
Availability: Unix.
...
@@ -145,7 +155,9 @@ process and user.
...
@@ -145,7 +155,9 @@ process and user.
Call the system initgroups() to initialize the group access list with all of
Call the system initgroups() to initialize the group access list with all of
the groups of which the specified username is a member, plus the specified
the groups of which the specified username is a member, plus the specified
group id. Availability: Unix.
group id.
Availability: Unix.
.. versionadded:: 2.7
.. versionadded:: 2.7
...
@@ -156,13 +168,17 @@ process and user.
...
@@ -156,13 +168,17 @@ process and user.
process. For most purposes, it is more useful to use the environment variable
process. For most purposes, it is more useful to use the environment variable
:envvar:`LOGNAME` to find out who the user is, or
:envvar:`LOGNAME` to find out who the user is, or
``pwd.getpwuid(os.getuid())[0]`` to get the login name of the currently
``pwd.getpwuid(os.getuid())[0]`` to get the login name of the currently
effective user id. Availability: Unix.
effective user id.
Availability: Unix.
.. function:: getpgid(pid)
.. function:: getpgid(pid)
Return the process group id of the process with process id *pid*. If *pid* is 0,
Return the process group id of the process with process id *pid*. If *pid* is 0,
the process group id of the current process is returned. Availability: Unix.
the process group id of the current process is returned.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -171,27 +187,35 @@ process and user.
...
@@ -171,27 +187,35 @@ process and user.
.. index:: single: process; group
.. index:: single: process; group
Return the id of the current process group. Availability: Unix.
Return the id of the current process group.
Availability: Unix.
.. function:: getpid()
.. function:: getpid()
.. index:: single: process; id
.. index:: single: process; id
Return the current process id. Availability: Unix, Windows.
Return the current process id.
Availability: Unix, Windows.
.. function:: getppid()
.. function:: getppid()
.. index:: single: process; id of parent
.. index:: single: process; id of parent
Return the parent's process id. Availability: Unix.
Return the parent's process id.
Availability: Unix.
.. function:: getresuid()
.. function:: getresuid()
Return a tuple (ruid, euid, suid) denoting the current process's
Return a tuple (ruid, euid, suid) denoting the current process's
real, effective, and saved user ids. Availability: Unix.
real, effective, and saved user ids.
Availability: Unix.
.. versionadded:: 2.7
.. versionadded:: 2.7
...
@@ -199,7 +223,9 @@ process and user.
...
@@ -199,7 +223,9 @@ process and user.
.. function:: getresgid()
.. function:: getresgid()
Return a tuple (rgid, egid, sgid) denoting the current process's
Return a tuple (rgid, egid, sgid) denoting the current process's
real, effective, and saved user ids. Availability: Unix.
real, effective, and saved user ids.
Availability: Unix.
.. versionadded:: 2.7
.. versionadded:: 2.7
...
@@ -208,14 +234,17 @@ process and user.
...
@@ -208,14 +234,17 @@ process and user.
.. index:: single: user; id
.. index:: single: user; id
Return the current process's user id. Availability: Unix.
Return the current process's user id.
Availability: Unix.
.. function:: getenv(varname[, value])
.. function:: getenv(varname[, value])
Return the value of the environment variable *varname* if it exists, or *value*
Return the value of the environment variable *varname* if it exists, or *value*
if it doesn't. *value* defaults to ``None``. Availability: most flavors of
if it doesn't. *value* defaults to ``None``.
Unix, Windows.
Availability: most flavors of Unix, Windows.
.. function:: putenv(varname, value)
.. function:: putenv(varname, value)
...
@@ -224,8 +253,9 @@ process and user.
...
@@ -224,8 +253,9 @@ process and user.
Set the environment variable named *varname* to the string *value*. Such
Set the environment variable named *varname* to the string *value*. Such
changes to the environment affect subprocesses started with :func:`os.system`,
changes to the environment affect subprocesses started with :func:`os.system`,
:func:`popen` or :func:`fork` and :func:`execv`. Availability: most flavors of
:func:`popen` or :func:`fork` and :func:`execv`.
Unix, Windows.
Availability: most flavors of Unix, Windows.
.. note::
.. note::
...
@@ -240,17 +270,23 @@ process and user.
...
@@ -240,17 +270,23 @@ process and user.
.. function:: setegid(egid)
.. function:: setegid(egid)
Set the current process's effective group id. Availability: Unix.
Set the current process's effective group id.
Availability: Unix.
.. function:: seteuid(euid)
.. function:: seteuid(euid)
Set the current process's effective user id. Availability: Unix.
Set the current process's effective user id.
Availability: Unix.
.. function:: setgid(gid)
.. function:: setgid(gid)
Set the current process' group id. Availability: Unix.
Set the current process' group id.
Availability: Unix.
.. function:: setgroups(groups)
.. function:: setgroups(groups)
...
@@ -258,6 +294,7 @@ process and user.
...
@@ -258,6 +294,7 @@ process and user.
Set the list of supplemental group ids associated with the current process to
Set the list of supplemental group ids associated with the current process to
*groups*. *groups* must be a sequence, and each element must be an integer
*groups*. *groups* must be a sequence, and each element must be an integer
identifying a group. This operation is typically available only to the superuser.
identifying a group. This operation is typically available only to the superuser.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.2
.. versionadded:: 2.2
...
@@ -267,6 +304,7 @@ process and user.
...
@@ -267,6 +304,7 @@ process and user.
Call the system call :cfunc:`setpgrp` or :cfunc:`setpgrp(0, 0)` depending on
Call the system call :cfunc:`setpgrp` or :cfunc:`setpgrp(0, 0)` depending on
which version is implemented (if any). See the Unix manual for the semantics.
which version is implemented (if any). See the Unix manual for the semantics.
Availability: Unix.
Availability: Unix.
...
@@ -274,17 +312,22 @@ process and user.
...
@@ -274,17 +312,22 @@ process and user.
Call the system call :cfunc:`setpgid` to set the process group id of the
Call the system call :cfunc:`setpgid` to set the process group id of the
process with id *pid* to the process group with id *pgrp*. See the Unix manual
process with id *pid* to the process group with id *pgrp*. See the Unix manual
for the semantics. Availability: Unix.
for the semantics.
Availability: Unix.
.. function:: setregid(rgid, egid)
.. function:: setregid(rgid, egid)
Set the current process's real and effective group ids. Availability: Unix.
Set the current process's real and effective group ids.
Availability: Unix.
.. function:: setresgid(rgid, egid, sgid)
.. function:: setresgid(rgid, egid, sgid)
Set the current process's real, effective, and saved group ids.
Set the current process's real, effective, and saved group ids.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.7
.. versionadded:: 2.7
...
@@ -293,6 +336,7 @@ process and user.
...
@@ -293,6 +336,7 @@ process and user.
.. function:: setresuid(ruid, euid, suid)
.. function:: setresuid(ruid, euid, suid)
Set the current process's real, effective, and saved user ids.
Set the current process's real, effective, and saved user ids.
Availibility: Unix.
Availibility: Unix.
.. versionadded:: 2.7
.. versionadded:: 2.7
...
@@ -300,12 +344,15 @@ process and user.
...
@@ -300,12 +344,15 @@ process and user.
.. function:: setreuid(ruid, euid)
.. function:: setreuid(ruid, euid)
Set the current process's real and effective user ids. Availability: Unix.
Set the current process's real and effective user ids.
Availability: Unix.
.. function:: getsid(pid)
.. function:: getsid(pid)
Call the system call :cfunc:`getsid`. See the Unix manual for the semantics.
Call the system call :cfunc:`getsid`. See the Unix manual for the semantics.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.4
.. versionadded:: 2.4
...
@@ -314,6 +361,7 @@ process and user.
...
@@ -314,6 +361,7 @@ process and user.
.. function:: setsid()
.. function:: setsid()
Call the system call :cfunc:`setsid`. See the Unix manual for the semantics.
Call the system call :cfunc:`setsid`. See the Unix manual for the semantics.
Availability: Unix.
Availability: Unix.
...
@@ -321,7 +369,9 @@ process and user.
...
@@ -321,7 +369,9 @@ process and user.
.. index:: single: user; id, setting
.. index:: single: user; id, setting
Set the current process's user id. Availability: Unix.
Set the current process's user id.
Availability: Unix.
.. placed in this section since it relates to errno.... a little weak
.. placed in this section since it relates to errno.... a little weak
...
@@ -329,13 +379,16 @@ process and user.
...
@@ -329,13 +379,16 @@ process and user.
Return the error message corresponding to the error code in *code*.
Return the error message corresponding to the error code in *code*.
On platforms where :cfunc:`strerror` returns ``NULL`` when given an unknown
On platforms where :cfunc:`strerror` returns ``NULL`` when given an unknown
error number, :exc:`ValueError` is raised. Availability: Unix, Windows.
error number, :exc:`ValueError` is raised.
Availability: Unix, Windows.
.. function:: umask(mask)
.. function:: umask(mask)
Set the current numeric umask and return the previous umask. Availability:
Set the current numeric umask and return the previous umask.
Unix, Windows.
Availability: Unix, Windows.
.. function:: uname()
.. function:: uname()
...
@@ -349,8 +402,9 @@ process and user.
...
@@ -349,8 +402,9 @@ process and user.
machine)``. Some systems truncate the nodename to 8 characters or to the
machine)``. Some systems truncate the nodename to 8 characters or to the
leading component; a better way to get the hostname is
leading component; a better way to get the hostname is
:func:`socket.gethostname` or even
:func:`socket.gethostname` or even
``socket.gethostbyaddr(socket.gethostname())``. Availability: recent flavors of
``socket.gethostbyaddr(socket.gethostname())``.
Unix.
Availability: recent flavors of Unix.
.. function:: unsetenv(varname)
.. function:: unsetenv(varname)
...
@@ -359,13 +413,15 @@ process and user.
...
@@ -359,13 +413,15 @@ process and user.
Unset (delete) the environment variable named *varname*. Such changes to the
Unset (delete) the environment variable named *varname*. Such changes to the
environment affect subprocesses started with :func:`os.system`, :func:`popen` or
environment affect subprocesses started with :func:`os.system`, :func:`popen` or
:func:`fork` and :func:`execv`.
Availability: most flavors of Unix, Windows.
:func:`fork` and :func:`execv`.
When :func:`unsetenv` is supported, deletion of items in ``os.environ`` is
When :func:`unsetenv` is supported, deletion of items in ``os.environ`` is
automatically translated into a corresponding call to :func:`unsetenv`; however,
automatically translated into a corresponding call to :func:`unsetenv`; however,
calls to :func:`unsetenv` don't update ``os.environ``, so it is actually
calls to :func:`unsetenv` don't update ``os.environ``, so it is actually
preferable to delete items of ``os.environ``.
preferable to delete items of ``os.environ``.
Availability: most flavors of Unix, Windows.
.. _os-newstreams:
.. _os-newstreams:
...
@@ -381,7 +437,9 @@ These functions create new file objects. (See also :func:`open`.)
...
@@ -381,7 +437,9 @@ These functions create new file objects. (See also :func:`open`.)
Return an open file object connected to the file descriptor *fd*. The *mode*
Return an open file object connected to the file descriptor *fd*. The *mode*
and *bufsize* arguments have the same meaning as the corresponding arguments to
and *bufsize* arguments have the same meaning as the corresponding arguments to
the built-in :func:`open` function. Availability: Unix, Windows.
the built-in :func:`open` function.
Availability: Unix, Windows.
.. versionchanged:: 2.3
.. versionchanged:: 2.3
When specified, the *mode* argument must now start with one of the letters
When specified, the *mode* argument must now start with one of the letters
...
@@ -402,7 +460,9 @@ These functions create new file objects. (See also :func:`open`.)
...
@@ -402,7 +460,9 @@ These functions create new file objects. (See also :func:`open`.)
status of the command (encoded in the format specified for :func:`wait`) is
status of the command (encoded in the format specified for :func:`wait`) is
available as the return value of the :meth:`~file.close` method of the file object,
available as the return value of the :meth:`~file.close` method of the file object,
except that when the exit status is zero (termination without errors), ``None``
except that when the exit status is zero (termination without errors), ``None``
is returned. Availability: Unix, Windows.
is returned.
Availability: Unix, Windows.
.. deprecated:: 2.6
.. deprecated:: 2.6
This function is obsolete. Use the :mod:`subprocess` module. Check
This function is obsolete. Use the :mod:`subprocess` module. Check
...
@@ -419,8 +479,9 @@ These functions create new file objects. (See also :func:`open`.)
...
@@ -419,8 +479,9 @@ These functions create new file objects. (See also :func:`open`.)
Return a new file object opened in update mode (``w+b``). The file has no
Return a new file object opened in update mode (``w+b``). The file has no
directory entries associated with it and will be automatically deleted once
directory entries associated with it and will be automatically deleted once
there are no file descriptors for the file. Availability: Unix,
there are no file descriptors for the file.
Windows.
Availability: Unix, Windows.
There are a number of different :func:`popen\*` functions that provide slightly
There are a number of different :func:`popen\*` functions that provide slightly
different ways to create subprocesses.
different ways to create subprocesses.
...
@@ -520,7 +581,9 @@ as internal buffering of data.
...
@@ -520,7 +581,9 @@ as internal buffering of data.
.. function:: close(fd)
.. function:: close(fd)
Close file descriptor *fd*. Availability: Unix, Windows.
Close file descriptor *fd*.
Availability: Unix, Windows.
.. note::
.. note::
...
@@ -533,7 +596,7 @@ as internal buffering of data.
...
@@ -533,7 +596,7 @@ as internal buffering of data.
.. function:: closerange(fd_low, fd_high)
.. function:: closerange(fd_low, fd_high)
Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive),
Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive),
ignoring errors.
Availability: Unix, Windows.
Equivalent to::
ignoring errors. Equivalent to::
for fd in xrange(fd_low, fd_high):
for fd in xrange(fd_low, fd_high):
try:
try:
...
@@ -541,25 +604,31 @@ as internal buffering of data.
...
@@ -541,25 +604,31 @@ as internal buffering of data.
except OSError:
except OSError:
pass
pass
Availability: Unix, Windows.
.. versionadded:: 2.6
.. versionadded:: 2.6
.. function:: dup(fd)
.. function:: dup(fd)
Return a duplicate of file descriptor *fd*. Availability: Unix,
Return a duplicate of file descriptor *fd*.
Windows.
Availability: Unix, Windows.
.. function:: dup2(fd, fd2)
.. function:: dup2(fd, fd2)
Duplicate file descriptor *fd* to *fd2*, closing the latter first if necessary.
Duplicate file descriptor *fd* to *fd2*, closing the latter first if necessary.
Availability: Unix, Windows.
Availability: Unix, Windows.
.. function:: fchmod(fd, mode)
.. function:: fchmod(fd, mode)
Change the mode of the file given by *fd* to the numeric *mode*. See the docs
Change the mode of the file given by *fd* to the numeric *mode*. See the docs
for :func:`chmod` for possible values of *mode*. Availability: Unix.
for :func:`chmod` for possible values of *mode*.
Availability: Unix.
.. versionadded:: 2.6
.. versionadded:: 2.6
...
@@ -568,6 +637,7 @@ as internal buffering of data.
...
@@ -568,6 +637,7 @@ as internal buffering of data.
Change the owner and group id of the file given by *fd* to the numeric *uid*
Change the owner and group id of the file given by *fd* to the numeric *uid*
and *gid*. To leave one of the ids unchanged, set it to -1.
and *gid*. To leave one of the ids unchanged, set it to -1.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.6
.. versionadded:: 2.6
...
@@ -576,7 +646,9 @@ as internal buffering of data.
...
@@ -576,7 +646,9 @@ as internal buffering of data.
.. function:: fdatasync(fd)
.. function:: fdatasync(fd)
Force write of file with filedescriptor *fd* to disk. Does not force update of
Force write of file with filedescriptor *fd* to disk. Does not force update of
metadata. Availability: Unix.
metadata.
Availability: Unix.
.. note::
.. note::
This function is not available on MacOS.
This function is not available on MacOS.
...
@@ -591,24 +663,28 @@ as internal buffering of data.
...
@@ -591,24 +663,28 @@ as internal buffering of data.
additional names as well. The names known to the host operating system are
additional names as well. The names known to the host operating system are
given in the ``pathconf_names`` dictionary. For configuration variables not
given in the ``pathconf_names`` dictionary. For configuration variables not
included in that mapping, passing an integer for *name* is also accepted.
included in that mapping, passing an integer for *name* is also accepted.
Availability: Unix.
If *name* is a string and is not known, :exc:`ValueError` is raised. If a
If *name* is a string and is not known, :exc:`ValueError` is raised. If a
specific value for *name* is not supported by the host system, even if it is
specific value for *name* is not supported by the host system, even if it is
included in ``pathconf_names``, an :exc:`OSError` is raised with
included in ``pathconf_names``, an :exc:`OSError` is raised with
:const:`errno.EINVAL` for the error number.
:const:`errno.EINVAL` for the error number.
Availability: Unix.
.. function:: fstat(fd)
.. function:: fstat(fd)
Return status for file descriptor *fd*, like :func:`stat`. Availability:
Return status for file descriptor *fd*, like :func:`stat`.
Unix, Windows.
Availability: Unix, Windows.
.. function:: fstatvfs(fd)
.. function:: fstatvfs(fd)
Return information about the filesystem containing the file associated with file
Return information about the filesystem containing the file associated with file
descriptor *fd*, like :func:`statvfs`. Availability: Unix.
descriptor *fd*, like :func:`statvfs`.
Availability: Unix.
.. function:: fsync(fd)
.. function:: fsync(fd)
...
@@ -618,20 +694,25 @@ as internal buffering of data.
...
@@ -618,20 +694,25 @@ as internal buffering of data.
If you're starting with a Python file object *f*, first do ``f.flush()``, and
If you're starting with a Python file object *f*, first do ``f.flush()``, and
then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated
then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated
with *f* are written to disk. Availability: Unix, and Windows
with *f* are written to disk.
starting in 2.2.3.
Availability: Unix, and Windows starting in 2.2.3.
.. function:: ftruncate(fd, length)
.. function:: ftruncate(fd, length)
Truncate the file corresponding to file descriptor *fd*, so that it is at most
Truncate the file corresponding to file descriptor *fd*, so that it is at most
*length* bytes in size. Availability: Unix.
*length* bytes in size.
Availability: Unix.
.. function:: isatty(fd)
.. function:: isatty(fd)
Return ``True`` if the file descriptor *fd* is open and connected to a
Return ``True`` if the file descriptor *fd* is open and connected to a
tty(-like) device, else ``False``. Availability: Unix.
tty(-like) device, else ``False``.
Availability: Unix.
.. function:: lseek(fd, pos, how)
.. function:: lseek(fd, pos, how)
...
@@ -640,7 +721,9 @@ as internal buffering of data.
...
@@ -640,7 +721,9 @@ as internal buffering of data.
by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the
by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the
beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the
beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the
current position; :const:`os.SEEK_END` or ``2`` to set it relative to the end of
current position; :const:`os.SEEK_END` or ``2`` to set it relative to the end of
the file. Availability: Unix, Windows.
the file.
Availability: Unix, Windows.
.. data:: SEEK_SET
.. data:: SEEK_SET
...
@@ -648,7 +731,9 @@ as internal buffering of data.
...
@@ -648,7 +731,9 @@ as internal buffering of data.
SEEK_END
SEEK_END
Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
respectively. Availability: Windows, Unix.
respectively.
Availability: Windows, Unix.
.. versionadded:: 2.5
.. versionadded:: 2.5
...
@@ -658,18 +743,20 @@ as internal buffering of data.
...
@@ -658,18 +743,20 @@ as internal buffering of data.
Open the file *file* and set various flags according to *flags* and possibly its
Open the file *file* and set various flags according to *flags* and possibly its
mode according to *mode*. The default *mode* is ``0777`` (octal), and the
mode according to *mode*. The default *mode* is ``0777`` (octal), and the
current umask value is first masked out. Return the file descriptor for the
current umask value is first masked out. Return the file descriptor for the
newly opened file.
Availability: Unix, Windows.
newly opened file.
For a description of the flag and mode values, see the C run-time documentation;
For a description of the flag and mode values, see the C run-time documentation;
flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
this module too (see :ref:`open-constants`). In particular, on Windows adding
this module too (see :ref:`open-constants`). In particular, on Windows adding
:const:`O_BINARY` is needed to open files in binary mode.
:const:`O_BINARY` is needed to open files in binary mode.
Availability: Unix, Windows.
.. note::
.. note::
This function is intended for low-level I/O. For normal usage, use the
This function is intended for low-level I/O. For normal usage, use the
built-in function :func:`open`, which returns a "file object" with
built-in function :func:`open`, which returns a "file object" with
:meth:`~file.read` and :meth:`~file.write` methods (and many more). To
:meth:`~file.read` and :meth:`~file.w
p
rite` methods (and many more). To
wrap a file descriptor in a "file object", use :func:`fdopen`.
wrap a file descriptor in a "file object", use :func:`fdopen`.
...
@@ -679,21 +766,26 @@ as internal buffering of data.
...
@@ -679,21 +766,26 @@ as internal buffering of data.
Open a new pseudo-terminal pair. Return a pair of file descriptors ``(master,
Open a new pseudo-terminal pair. Return a pair of file descriptors ``(master,
slave)`` for the pty and the tty, respectively. For a (slightly) more portable
slave)`` for the pty and the tty, respectively. For a (slightly) more portable
approach, use the :mod:`pty` module. Availability: some flavors of
approach, use the :mod:`pty` module.
Unix.
Availability: some flavors of Unix.
.. function:: pipe()
.. function:: pipe()
Create a pipe. Return a pair of file descriptors ``(r, w)`` usable for reading
Create a pipe. Return a pair of file descriptors ``(r, w)`` usable for reading
and writing, respectively. Availability: Unix, Windows.
and writing, respectively.
Availability: Unix, Windows.
.. function:: read(fd, n)
.. function:: read(fd, n)
Read at most *n* bytes from file descriptor *fd*. Return a string containing the
Read at most *n* bytes from file descriptor *fd*. Return a string containing the
bytes read. If the end of the file referred to by *fd* has been reached, an
bytes read. If the end of the file referred to by *fd* has been reached, an
empty string is returned. Availability: Unix, Windows.
empty string is returned.
Availability: Unix, Windows.
.. note::
.. note::
...
@@ -707,26 +799,34 @@ as internal buffering of data.
...
@@ -707,26 +799,34 @@ as internal buffering of data.
.. function:: tcgetpgrp(fd)
.. function:: tcgetpgrp(fd)
Return the process group associated with the terminal given by *fd* (an open
Return the process group associated with the terminal given by *fd* (an open
file descriptor as returned by :func:`os.open`). Availability: Unix.
file descriptor as returned by :func:`os.open`).
Availability: Unix.
.. function:: tcsetpgrp(fd, pg)
.. function:: tcsetpgrp(fd, pg)
Set the process group associated with the terminal given by *fd* (an open file
Set the process group associated with the terminal given by *fd* (an open file
descriptor as returned by :func:`os.open`) to *pg*. Availability: Unix.
descriptor as returned by :func:`os.open`) to *pg*.
Availability: Unix.
.. function:: ttyname(fd)
.. function:: ttyname(fd)
Return a string which specifies the terminal device associated with
Return a string which specifies the terminal device associated with
file descriptor *fd*. If *fd* is not associated with a terminal device, an
file descriptor *fd*. If *fd* is not associated with a terminal device, an
exception is raised. Availability: Unix.
exception is raised.
Availability: Unix.
.. function:: write(fd, str)
.. function:: write(fd, str)
Write the string *str* to file descriptor *fd*. Return the number of bytes
Write the string *str* to file descriptor *fd*. Return the number of bytes
actually written. Availability: Unix, Windows.
actually written.
Availability: Unix, Windows.
.. note::
.. note::
...
@@ -807,7 +907,9 @@ Files and Directories
...
@@ -807,7 +907,9 @@ Files and Directories
can be the inclusive OR of one or more of :const:`R_OK`, :const:`W_OK`, and
can be the inclusive OR of one or more of :const:`R_OK`, :const:`W_OK`, and
:const:`X_OK` to test permissions. Return :const:`True` if access is allowed,
:const:`X_OK` to test permissions. Return :const:`True` if access is allowed,
:const:`False` if not. See the Unix man page :manpage:`access(2)` for more
:const:`False` if not. See the Unix man page :manpage:`access(2)` for more
information. Availability: Unix, Windows.
information.
Availability: Unix, Windows.
.. note::
.. note::
...
@@ -851,28 +953,33 @@ Files and Directories
...
@@ -851,28 +953,33 @@ Files and Directories
.. index:: single: directory; changing
.. index:: single: directory; changing
Change the current working directory to *path*. Availability: Unix,
Change the current working directory to *path*.
Windows.
Availability: Unix, Windows.
.. function:: fchdir(fd)
.. function:: fchdir(fd)
Change the current working directory to the directory represented by the file
Change the current working directory to the directory represented by the file
descriptor *fd*. The descriptor must refer to an opened directory, not an open
descriptor *fd*. The descriptor must refer to an opened directory, not an open
file. Availability: Unix.
file.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
.. function:: getcwd()
.. function:: getcwd()
Return a string representing the current working directory. Availability:
Return a string representing the current working directory.
Unix, Windows.
Availability: Unix, Windows.
.. function:: getcwdu()
.. function:: getcwdu()
Return a Unicode object representing the current working directory.
Return a Unicode object representing the current working directory.
Availability: Unix, Windows.
Availability: Unix, Windows.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -947,13 +1054,17 @@ Files and Directories
...
@@ -947,13 +1054,17 @@ Files and Directories
.. function:: chown(path, uid, gid)
.. function:: chown(path, uid, gid)
Change the owner and group id of *path* to the numeric *uid* and *gid*. To leave
Change the owner and group id of *path* to the numeric *uid* and *gid*. To leave
one of the ids unchanged, set it to -1. Availability: Unix.
one of the ids unchanged, set it to -1.
Availability: Unix.
.. function:: lchflags(path, flags)
.. function:: lchflags(path, flags)
Set the flags of *path* to the numeric *flags*, like :func:`chflags`, but do not
Set the flags of *path* to the numeric *flags*, like :func:`chflags`, but do not
follow symbolic links. Availability: Unix.
follow symbolic links.
Availability: Unix.
.. versionadded:: 2.6
.. versionadded:: 2.6
...
@@ -962,7 +1073,9 @@ Files and Directories
...
@@ -962,7 +1073,9 @@ Files and Directories
Change the mode of *path* to the numeric *mode*. If path is a symlink, this
Change the mode of *path* to the numeric *mode*. If path is a symlink, this
affects the symlink rather than the target. See the docs for :func:`chmod`
affects the symlink rather than the target. See the docs for :func:`chmod`
for possible values of *mode*. Availability: Unix.
for possible values of *mode*.
Availability: Unix.
.. versionadded:: 2.6
.. versionadded:: 2.6
...
@@ -970,15 +1083,18 @@ Files and Directories
...
@@ -970,15 +1083,18 @@ Files and Directories
.. function:: lchown(path, uid, gid)
.. function:: lchown(path, uid, gid)
Change the owner and group id of *path* to the numeric *uid* and *gid*. This
Change the owner and group id of *path* to the numeric *uid* and *gid*. This
function will not follow symbolic links. Availability: Unix.
function will not follow symbolic links.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
.. function:: link(source, link_name)
.. function:: link(source, link_name)
Create a hard link pointing to *source* named *link_name*. Availability:
Create a hard link pointing to *source* named *link_name*.
Unix.
Availability: Unix.
.. function:: listdir(path)
.. function:: listdir(path)
...
@@ -986,7 +1102,9 @@ Files and Directories
...
@@ -986,7 +1102,9 @@ Files and Directories
Return a list containing the names of the entries in the directory given by
Return a list containing the names of the entries in the directory given by
*path*. The list is in arbitrary order. It does not include the special
*path*. The list is in arbitrary order. It does not include the special
entries ``'.'`` and ``'..'`` even if they are present in the
entries ``'.'`` and ``'..'`` even if they are present in the
directory. Availability: Unix, Windows.
directory.
Availability: Unix, Windows.
.. versionchanged:: 2.3
.. versionchanged:: 2.3
On Windows NT/2k/XP and Unix, if *path* is a Unicode object, the result will be
On Windows NT/2k/XP and Unix, if *path* is a Unicode object, the result will be
...
@@ -1005,7 +1123,9 @@ Files and Directories
...
@@ -1005,7 +1123,9 @@ Files and Directories
Create a FIFO (a named pipe) named *path* with numeric mode *mode*. The default
Create a FIFO (a named pipe) named *path* with numeric mode *mode*. The default
*mode* is ``0666`` (octal). The current umask value is first masked out from
*mode* is ``0666`` (octal). The current umask value is first masked out from
the mode. Availability: Unix.
the mode.
Availability: Unix.
FIFOs are pipes that can be accessed like regular files. FIFOs exist until they
FIFOs are pipes that can be accessed like regular files. FIFOs exist until they
are deleted (for example with :func:`os.unlink`). Generally, FIFOs are used as
are deleted (for example with :func:`os.unlink`). Generally, FIFOs are used as
...
@@ -1055,11 +1175,13 @@ Files and Directories
...
@@ -1055,11 +1175,13 @@ Files and Directories
Create a directory named *path* with numeric mode *mode*. The default *mode* is
Create a directory named *path* with numeric mode *mode*. The default *mode* is
``0777`` (octal). On some systems, *mode* is ignored. Where it is used, the
``0777`` (octal). On some systems, *mode* is ignored. Where it is used, the
current umask value is first masked out.
Availability: Unix, Windows.
current umask value is first masked out.
It is also possible to create temporary directories; see the
It is also possible to create temporary directories; see the
:mod:`tempfile` module's :func:`tempfile.mkdtemp` function.
:mod:`tempfile` module's :func:`tempfile.mkdtemp` function.
Availability: Unix, Windows.
.. function:: makedirs(path[, mode])
.. function:: makedirs(path[, mode])
...
@@ -1093,13 +1215,14 @@ Files and Directories
...
@@ -1093,13 +1215,14 @@ Files and Directories
additional names as well. The names known to the host operating system are
additional names as well. The names known to the host operating system are
given in the ``pathconf_names`` dictionary. For configuration variables not
given in the ``pathconf_names`` dictionary. For configuration variables not
included in that mapping, passing an integer for *name* is also accepted.
included in that mapping, passing an integer for *name* is also accepted.
Availability: Unix.
If *name* is a string and is not known, :exc:`ValueError` is raised. If a
If *name* is a string and is not known, :exc:`ValueError` is raised. If a
specific value for *name* is not supported by the host system, even if it is
specific value for *name* is not supported by the host system, even if it is
included in ``pathconf_names``, an :exc:`OSError` is raised with
included in ``pathconf_names``, an :exc:`OSError` is raised with
:const:`errno.EINVAL` for the error number.
:const:`errno.EINVAL` for the error number.
Availability: Unix.
.. data:: pathconf_names
.. data:: pathconf_names
...
@@ -1129,8 +1252,9 @@ Files and Directories
...
@@ -1129,8 +1252,9 @@ Files and Directories
the :func:`unlink` function documented below. On Windows, attempting to
the :func:`unlink` function documented below. On Windows, attempting to
remove a file that is in use causes an exception to be raised; on Unix, the
remove a file that is in use causes an exception to be raised; on Unix, the
directory entry is removed but the storage allocated to the file is not made
directory entry is removed but the storage allocated to the file is not made
available until the original file is no longer in use. Availability: Unix,
available until the original file is no longer in use.
Windows.
Availability: Unix, Windows.
.. function:: removedirs(path)
.. function:: removedirs(path)
...
@@ -1158,7 +1282,9 @@ Files and Directories
...
@@ -1158,7 +1282,9 @@ Files and Directories
the renaming will be an atomic operation (this is a POSIX requirement). On
the renaming will be an atomic operation (this is a POSIX requirement). On
Windows, if *dst* already exists, :exc:`OSError` will be raised even if it is a
Windows, if *dst* already exists, :exc:`OSError` will be raised even if it is a
file; there may be no way to implement an atomic rename when *dst* names an
file; there may be no way to implement an atomic rename when *dst* names an
existing file. Availability: Unix, Windows.
existing file.
Availability: Unix, Windows.
.. function:: renames(old, new)
.. function:: renames(old, new)
...
@@ -1180,8 +1306,9 @@ Files and Directories
...
@@ -1180,8 +1306,9 @@ Files and Directories
Remove (delete) the directory *path*. Only works when the directory is
Remove (delete) the directory *path*. Only works when the directory is
empty, otherwise, :exc:`OSError` is raised. In order to remove whole
empty, otherwise, :exc:`OSError` is raised. In order to remove whole
directory trees, :func:`shutil.rmtree` can be used. Availability: Unix,
directory trees, :func:`shutil.rmtree` can be used.
Windows.
Availability: Unix, Windows.
.. function:: stat(path)
.. function:: stat(path)
...
@@ -1287,7 +1414,7 @@ Files and Directories
...
@@ -1287,7 +1414,7 @@ Files and Directories
correspond to the members of the :ctype:`statvfs` structure, namely:
correspond to the members of the :ctype:`statvfs` structure, namely:
:attr:`f_bsize`, :attr:`f_frsize`, :attr:`f_blocks`, :attr:`f_bfree`,
:attr:`f_bsize`, :attr:`f_frsize`, :attr:`f_blocks`, :attr:`f_bfree`,
:attr:`f_bavail`, :attr:`f_files`, :attr:`f_ffree`, :attr:`f_favail`,
:attr:`f_bavail`, :attr:`f_files`, :attr:`f_ffree`, :attr:`f_favail`,
:attr:`f_flag`, :attr:`f_namemax`.
Availability: Unix.
:attr:`f_flag`, :attr:`f_namemax`.
.. index:: module: statvfs
.. index:: module: statvfs
...
@@ -1298,14 +1425,17 @@ Files and Directories
...
@@ -1298,14 +1425,17 @@ Files and Directories
this remains useful when writing code that needs to work with versions of Python
this remains useful when writing code that needs to work with versions of Python
that don't support accessing the fields as attributes.
that don't support accessing the fields as attributes.
Availability: Unix.
.. versionchanged:: 2.2
.. versionchanged:: 2.2
Added access to values as attributes of the returned object.
Added access to values as attributes of the returned object.
.. function:: symlink(source, link_name)
.. function:: symlink(source, link_name)
Create a symbolic link pointing to *source* named *link_name*. Availability:
Create a symbolic link pointing to *source* named *link_name*.
Unix.
Availability: Unix.
.. function:: tempnam([dir[, prefix]])
.. function:: tempnam([dir[, prefix]])
...
@@ -1359,7 +1489,9 @@ Files and Directories
...
@@ -1359,7 +1489,9 @@ Files and Directories
Remove (delete) the file *path*. This is the same function as
Remove (delete) the file *path*. This is the same function as
:func:`remove`; the :func:`unlink` name is its traditional Unix
:func:`remove`; the :func:`unlink` name is its traditional Unix
name. Availability: Unix, Windows.
name.
Availability: Unix, Windows.
.. function:: utime(path, times)
.. function:: utime(path, times)
...
@@ -1491,6 +1623,7 @@ to be ignored.
...
@@ -1491,6 +1623,7 @@ to be ignored.
behavior is to produce a core dump; on Windows, the process immediately returns
behavior is to produce a core dump; on Windows, the process immediately returns
an exit code of ``3``. Be aware that programs which use :func:`signal.signal`
an exit code of ``3``. Be aware that programs which use :func:`signal.signal`
to register a handler for :const:`SIGABRT` will behave differently.
to register a handler for :const:`SIGABRT` will behave differently.
Availability: Unix, Windows.
Availability: Unix, Windows.
...
@@ -1546,7 +1679,9 @@ to be ignored.
...
@@ -1546,7 +1679,9 @@ to be ignored.
.. function:: _exit(n)
.. function:: _exit(n)
Exit to the system with status *n*, without calling cleanup handlers, flushing
Exit to the system with status *n*, without calling cleanup handlers, flushing
stdio buffers, etc. Availability: Unix, Windows.
stdio buffers, etc.
Availability: Unix, Windows.
.. note::
.. note::
...
@@ -1566,7 +1701,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1566,7 +1701,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_OK
.. data:: EX_OK
Exit code that means no error occurred. Availability: Unix.
Exit code that means no error occurred.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1574,14 +1711,18 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1574,14 +1711,18 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_USAGE
.. data:: EX_USAGE
Exit code that means the command was used incorrectly, such as when the wrong
Exit code that means the command was used incorrectly, such as when the wrong
number of arguments are given. Availability: Unix.
number of arguments are given.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
.. data:: EX_DATAERR
.. data:: EX_DATAERR
Exit code that means the input data was incorrect. Availability: Unix.
Exit code that means the input data was incorrect.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1589,6 +1730,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1589,6 +1730,7 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_NOINPUT
.. data:: EX_NOINPUT
Exit code that means an input file did not exist or was not readable.
Exit code that means an input file did not exist or was not readable.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1596,30 +1738,36 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1596,30 +1738,36 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_NOUSER
.. data:: EX_NOUSER
Exit code that means a specified user did not exist. Availability: Unix.
Exit code that means a specified user did not exist.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
.. data:: EX_NOHOST
.. data:: EX_NOHOST
Exit code that means a specified host did not exist. Availability: Unix.
Exit code that means a specified host did not exist.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
.. data:: EX_UNAVAILABLE
.. data:: EX_UNAVAILABLE
Exit code that means that a required service is unavailable. Availability:
Exit code that means that a required service is unavailable.
Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
.. data:: EX_SOFTWARE
.. data:: EX_SOFTWARE
Exit code that means an internal software error was detected. Availability:
Exit code that means an internal software error was detected.
Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1627,7 +1775,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1627,7 +1775,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_OSERR
.. data:: EX_OSERR
Exit code that means an operating system error was detected, such as the
Exit code that means an operating system error was detected, such as the
inability to fork or create a pipe. Availability: Unix.
inability to fork or create a pipe.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1635,7 +1785,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1635,7 +1785,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_OSFILE
.. data:: EX_OSFILE
Exit code that means some system file did not exist, could not be opened, or had
Exit code that means some system file did not exist, could not be opened, or had
some other kind of error. Availability: Unix.
some other kind of error.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1643,6 +1795,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1643,6 +1795,7 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_CANTCREAT
.. data:: EX_CANTCREAT
Exit code that means a user specified output file could not be created.
Exit code that means a user specified output file could not be created.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1651,6 +1804,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1651,6 +1804,7 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_IOERR
.. data:: EX_IOERR
Exit code that means that an error occurred while doing I/O on some file.
Exit code that means that an error occurred while doing I/O on some file.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1660,7 +1814,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1660,7 +1814,9 @@ written in Python, such as a mail server's external command delivery program.
Exit code that means a temporary failure occurred. This indicates something
Exit code that means a temporary failure occurred. This indicates something
that may not really be an error, such as a network connection that couldn't be
that may not really be an error, such as a network connection that couldn't be
made during a retryable operation. Availability: Unix.
made during a retryable operation.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1668,7 +1824,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1668,7 +1824,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_PROTOCOL
.. data:: EX_PROTOCOL
Exit code that means that a protocol exchange was illegal, invalid, or not
Exit code that means that a protocol exchange was illegal, invalid, or not
understood. Availability: Unix.
understood.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1676,7 +1834,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1676,7 +1834,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_NOPERM
.. data:: EX_NOPERM
Exit code that means that there were insufficient permissions to perform the
Exit code that means that there were insufficient permissions to perform the
operation (but not intended for file system problems). Availability: Unix.
operation (but not intended for file system problems).
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1684,6 +1844,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1684,6 +1844,7 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_CONFIG
.. data:: EX_CONFIG
Exit code that means that some kind of configuration error occurred.
Exit code that means that some kind of configuration error occurred.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1691,8 +1852,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1691,8 +1852,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: EX_NOTFOUND
.. data:: EX_NOTFOUND
Exit code that means something like "an entry was not found". Availability:
Exit code that means something like "an entry was not found".
Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1715,6 +1877,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1715,6 +1877,7 @@ written in Python, such as a mail server's external command delivery program.
new child's process id in the parent, and *fd* is the file descriptor of the
new child's process id in the parent, and *fd* is the file descriptor of the
master end of the pseudo-terminal. For a more portable approach, use the
master end of the pseudo-terminal. For a more portable approach, use the
:mod:`pty` module. If an error occurs :exc:`OSError` is raised.
:mod:`pty` module. If an error occurs :exc:`OSError` is raised.
Availability: some flavors of Unix.
Availability: some flavors of Unix.
...
@@ -1744,7 +1907,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1744,7 +1907,9 @@ written in Python, such as a mail server's external command delivery program.
single: process; killing
single: process; killing
single: process; signalling
single: process; signalling
Send the signal *sig* to the process group *pgid*. Availability: Unix.
Send the signal *sig* to the process group *pgid*.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -1752,13 +1917,16 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1752,13 +1917,16 @@ written in Python, such as a mail server's external command delivery program.
.. function:: nice(increment)
.. function:: nice(increment)
Add *increment* to the process's "niceness". Return the new niceness.
Add *increment* to the process's "niceness". Return the new niceness.
Availability: Unix.
Availability: Unix.
.. function:: plock(op)
.. function:: plock(op)
Lock program segments into memory. The value of *op* (defined in
Lock program segments into memory. The value of *op* (defined in
``<sys/lock.h>``) determines which segments are locked. Availability: Unix.
``<sys/lock.h>``) determines which segments are locked.
Availability: Unix.
.. function:: popen(...)
.. function:: popen(...)
...
@@ -1842,7 +2010,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1842,7 +2010,9 @@ written in Python, such as a mail server's external command delivery program.
Possible values for the *mode* parameter to the :func:`spawn\*` family of
Possible values for the *mode* parameter to the :func:`spawn\*` family of
functions. If either of these values is given, the :func:`spawn\*` functions
functions. If either of these values is given, the :func:`spawn\*` functions
will return as soon as the new process has been created, with the process id as
will return as soon as the new process has been created, with the process id as
the return value. Availability: Unix, Windows.
the return value.
Availability: Unix, Windows.
.. versionadded:: 1.6
.. versionadded:: 1.6
...
@@ -1853,7 +2023,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1853,7 +2023,9 @@ written in Python, such as a mail server's external command delivery program.
functions. If this is given as *mode*, the :func:`spawn\*` functions will not
functions. If this is given as *mode*, the :func:`spawn\*` functions will not
return until the new process has run to completion and will return the exit code
return until the new process has run to completion and will return the exit code
of the process the run is successful, or ``-signal`` if a signal kills the
of the process the run is successful, or ``-signal`` if a signal kills the
process. Availability: Unix, Windows.
process.
Availability: Unix, Windows.
.. versionadded:: 1.6
.. versionadded:: 1.6
...
@@ -1866,6 +2038,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1866,6 +2038,7 @@ written in Python, such as a mail server's external command delivery program.
is similar to :const:`P_NOWAIT`, but the new process is detached from the
is similar to :const:`P_NOWAIT`, but the new process is detached from the
console of the calling process. If :const:`P_OVERLAY` is used, the current
console of the calling process. If :const:`P_OVERLAY` is used, the current
process will be replaced; the :func:`spawn\*` function will not return.
process will be replaced; the :func:`spawn\*` function will not return.
Availability: Windows.
Availability: Windows.
.. versionadded:: 1.6
.. versionadded:: 1.6
...
@@ -1891,7 +2064,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1891,7 +2064,9 @@ written in Python, such as a mail server's external command delivery program.
directory. If you want to use an absolute path, make sure the first character
directory. If you want to use an absolute path, make sure the first character
is not a slash (``'/'``); the underlying Win32 :cfunc:`ShellExecute` function
is not a slash (``'/'``); the underlying Win32 :cfunc:`ShellExecute` function
doesn't work if it is. Use the :func:`os.path.normpath` function to ensure that
doesn't work if it is. Use the :func:`os.path.normpath` function to ensure that
the path is properly encoded for Win32. Availability: Windows.
the path is properly encoded for Win32.
Availability: Windows.
.. versionadded:: 2.0
.. versionadded:: 2.0
...
@@ -1918,22 +2093,24 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1918,22 +2093,24 @@ written in Python, such as a mail server's external command delivery program.
the command run; on systems using a non-native shell, consult your shell
the command run; on systems using a non-native shell, consult your shell
documentation.
documentation.
Availability: Unix, Windows.
The :mod:`subprocess` module provides more powerful facilities for spawning new
The :mod:`subprocess` module provides more powerful facilities for spawning new
processes and retrieving their results; using that module is preferable to using
processes and retrieving their results; using that module is preferable to using
this function. Use the :mod:`subprocess` module. Check especially the
this function. Use the :mod:`subprocess` module. Check especially the
:ref:`subprocess-replacements` section.
:ref:`subprocess-replacements` section.
Availability: Unix, Windows.
.. function:: times()
.. function:: times()
Return a 5-tuple of floating point numbers indicating accumulated (processor or
Return a 5-tuple of floating point numbers indicating accumulated (processor
other) times, in seconds. The items are: user time, system time, children's
or other) times, in seconds. The items are: user time, system time,
user time, children's system time, and elapsed real time since a fixed point in
children's user time, children's system time, and elapsed real time since a
the past, in that order. See the Unix manual page :manpage:`times(2)` or the
fixed point in the past, in that order. See the Unix manual page
corresponding Windows Platform API documentation. Availability: Unix,
:manpage:`times(2)` or the corresponding Windows Platform API documentation.
Windows. On Windows, only the first two items are filled, the others are zero.
On Windows, only the first two items are filled, the others are zero.
Availability: Unix, Windows
.. function:: wait()
.. function:: wait()
...
@@ -1942,7 +2119,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1942,7 +2119,9 @@ written in Python, such as a mail server's external command delivery program.
and exit status indication: a 16-bit number, whose low byte is the signal number
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
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
number is zero); the high bit of the low byte is set if a core file was
produced. Availability: Unix.
produced.
Availability: Unix.
.. function:: waitpid(pid, options)
.. function:: waitpid(pid, options)
...
@@ -1980,6 +2159,7 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1980,6 +2159,7 @@ written in Python, such as a mail server's external command delivery program.
resource usage information is returned. Refer to :mod:`resource`.\
resource usage information is returned. Refer to :mod:`resource`.\
:func:`getrusage` for details on resource usage information. The option
:func:`getrusage` for details on resource usage information. The option
argument is the same as that provided to :func:`waitpid` and :func:`wait4`.
argument is the same as that provided to :func:`waitpid` and :func:`wait4`.
Availability: Unix.
Availability: Unix.
.. versionadded:: 2.5
.. versionadded:: 2.5
...
@@ -1991,7 +2171,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -1991,7 +2171,9 @@ written in Python, such as a mail server's external command delivery program.
process id, exit status indication, and resource usage information is returned.
process id, exit status indication, and resource usage information is returned.
Refer to :mod:`resource`.\ :func:`getrusage` for details on resource usage
Refer to :mod:`resource`.\ :func:`getrusage` for details on resource usage
information. The arguments to :func:`wait4` are the same as those provided to
information. The arguments to :func:`wait4` are the same as those provided to
:func:`waitpid`. Availability: Unix.
:func:`waitpid`.
Availability: Unix.
.. versionadded:: 2.5
.. versionadded:: 2.5
...
@@ -2000,14 +2182,16 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -2000,14 +2182,16 @@ written in Python, such as a mail server's external command delivery program.
The option for :func:`waitpid` to return immediately if no child process status
The option for :func:`waitpid` to return immediately if no child process status
is available immediately. The function returns ``(0, 0)`` in this case.
is available immediately. The function returns ``(0, 0)`` in this case.
Availability: Unix.
Availability: Unix.
.. data:: WCONTINUED
.. data:: WCONTINUED
This option causes child processes to be reported if they have been continued
This option causes child processes to be reported if they have been continued
from a job control stop since their status was last reported. Availability: Some
from a job control stop since their status was last reported.
Unix systems.
Availability: Some Unix systems.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -2015,8 +2199,9 @@ written in Python, such as a mail server's external command delivery program.
...
@@ -2015,8 +2199,9 @@ written in Python, such as a mail server's external command delivery program.
.. data:: WUNTRACED
.. data:: WUNTRACED
This option causes child processes to be reported if they have been stopped but
This option causes child processes to be reported if they have been stopped but
their current state has not been reported since they were stopped. Availability:
their current state has not been reported since they were stopped.
Unix.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -2028,7 +2213,9 @@ used to determine the disposition of a process.
...
@@ -2028,7 +2213,9 @@ used to determine the disposition of a process.
.. function:: WCOREDUMP(status)
.. function:: WCOREDUMP(status)
Return ``True`` if a core dump was generated for the process, otherwise
Return ``True`` if a core dump was generated for the process, otherwise
return ``False``. Availability: Unix.
return ``False``.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -2036,7 +2223,9 @@ used to determine the disposition of a process.
...
@@ -2036,7 +2223,9 @@ used to determine the disposition of a process.
.. function:: WIFCONTINUED(status)
.. function:: WIFCONTINUED(status)
Return ``True`` if the process has been continued from a job control stop,
Return ``True`` if the process has been continued from a job control stop,
otherwise return ``False``. Availability: Unix.
otherwise return ``False``.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -2044,36 +2233,47 @@ used to determine the disposition of a process.
...
@@ -2044,36 +2233,47 @@ used to determine the disposition of a process.
.. function:: WIFSTOPPED(status)
.. function:: WIFSTOPPED(status)
Return ``True`` if the process has been stopped, otherwise return
Return ``True`` if the process has been stopped, otherwise return
``False``. Availability: Unix.
``False``.
Availability: Unix.
.. function:: WIFSIGNALED(status)
.. function:: WIFSIGNALED(status)
Return ``True`` if the process exited due to a signal, otherwise return
Return ``True`` if the process exited due to a signal, otherwise return
``False``. Availability: Unix.
``False``.
Availability: Unix.
.. function:: WIFEXITED(status)
.. function:: WIFEXITED(status)
Return ``True`` if the process exited using the :manpage:`exit(2)` system call,
Return ``True`` if the process exited using the :manpage:`exit(2)` system call,
otherwise return ``False``. Availability: Unix.
otherwise return ``False``.
Availability: Unix.
.. function:: WEXITSTATUS(status)
.. function:: WEXITSTATUS(status)
If ``WIFEXITED(status)`` is true, return the integer parameter to the
If ``WIFEXITED(status)`` is true, return the integer parameter to the
:manpage:`exit(2)` system call. Otherwise, the return value is meaningless.
:manpage:`exit(2)` system call. Otherwise, the return value is meaningless.
Availability: Unix.
Availability: Unix.
.. function:: WSTOPSIG(status)
.. function:: WSTOPSIG(status)
Return the signal which caused the process to stop. Availability: Unix.
Return the signal which caused the process to stop.
Availability: Unix.
.. function:: WTERMSIG(status)
.. function:: WTERMSIG(status)
Return the signal which caused the process to exit. Availability: Unix.
Return the signal which caused the process to exit.
Availability: Unix.
.. _os-path:
.. _os-path:
...
@@ -2090,8 +2290,7 @@ Miscellaneous System Information
...
@@ -2090,8 +2290,7 @@ Miscellaneous System Information
Unix 95, Unix 98, and others). Some platforms define additional names as well.
Unix 95, Unix 98, and others). Some platforms define additional names as well.
The names known to the host operating system are given as the keys of the
The names known to the host operating system are given as the keys of the
``confstr_names`` dictionary. For configuration variables not included in that
``confstr_names`` dictionary. For configuration variables not included in that
mapping, passing an integer for *name* is also accepted. Availability:
mapping, passing an integer for *name* is also accepted.
Unix.
If the configuration value specified by *name* isn't defined, ``None`` is
If the configuration value specified by *name* isn't defined, ``None`` is
returned.
returned.
...
@@ -2101,19 +2300,25 @@ Miscellaneous System Information
...
@@ -2101,19 +2300,25 @@ Miscellaneous System Information
included in ``confstr_names``, an :exc:`OSError` is raised with
included in ``confstr_names``, an :exc:`OSError` is raised with
:const:`errno.EINVAL` for the error number.
:const:`errno.EINVAL` for the error number.
Availability: Unix
.. data:: confstr_names
.. data:: confstr_names
Dictionary mapping names accepted by :func:`confstr` to the integer values
Dictionary mapping names accepted by :func:`confstr` to the integer values
defined for those names by the host operating system. This can be used to
defined for those names by the host operating system. This can be used to
determine the set of names known to the system. Availability: Unix.
determine the set of names known to the system.
Availability: Unix.
.. function:: getloadavg()
.. function:: getloadavg()
Return the number of processes in the system run queue averaged over the last
Return the number of processes in the system run queue averaged over the last
1, 5, and 15 minutes or raises :exc:`OSError` if the load average was
1, 5, and 15 minutes or raises :exc:`OSError` if the load average was
unobtainable. Availability: Unix.
unobtainable.
Availability: Unix.
.. versionadded:: 2.3
.. versionadded:: 2.3
...
@@ -2124,6 +2329,7 @@ Miscellaneous System Information
...
@@ -2124,6 +2329,7 @@ Miscellaneous System Information
specified by *name* isn't defined, ``-1`` is returned. The comments regarding
specified by *name* isn't defined, ``-1`` is returned. The comments regarding
the *name* parameter for :func:`confstr` apply here as well; the dictionary that
the *name* parameter for :func:`confstr` apply here as well; the dictionary that
provides information on the known names is given by ``sysconf_names``.
provides information on the known names is given by ``sysconf_names``.
Availability: Unix.
Availability: Unix.
...
@@ -2131,7 +2337,9 @@ Miscellaneous System Information
...
@@ -2131,7 +2337,9 @@ Miscellaneous System Information
Dictionary mapping names accepted by :func:`sysconf` to the integer values
Dictionary mapping names accepted by :func:`sysconf` to the integer values
defined for those names by the host operating system. This can be used to
defined for those names by the host operating system. This can be used to
determine the set of names known to the system. Availability: Unix.
determine the set of names known to the system.
Availability: Unix.
The following data values are used to support path manipulation operations. These
The following data values are used to support path manipulation operations. These
are defined for all platforms.
are defined for all platforms.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment