diff options
Diffstat (limited to 'devdocs/python~3.12/library%2Fposix.html')
| -rw-r--r-- | devdocs/python~3.12/library%2Fposix.html | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fposix.html b/devdocs/python~3.12/library%2Fposix.html new file mode 100644 index 00000000..08fb6769 --- /dev/null +++ b/devdocs/python~3.12/library%2Fposix.html @@ -0,0 +1,13 @@ + <span id="posix-the-most-common-posix-system-calls"></span><h1>posix — The most common POSIX system calls</h1> <p>This module provides access to operating system functionality that is standardized by the C Standard and the POSIX standard (a thinly disguised Unix interface).</p> <div class="availability docutils container"> <p><a class="reference internal" href="https://docs.python.org/3.12/library/intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix.</p> </div> <p id="index-0"><strong>Do not import this module directly.</strong> Instead, import the module <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a>, which provides a <em>portable</em> version of this interface. On Unix, the <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> module provides a superset of the <a class="reference internal" href="#module-posix" title="posix: The most common POSIX system calls (normally used via module os). (Unix)"><code>posix</code></a> interface. On non-Unix operating systems the <a class="reference internal" href="#module-posix" title="posix: The most common POSIX system calls (normally used via module os). (Unix)"><code>posix</code></a> module is not available, but a subset is always available through the <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> interface. Once <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> is imported, there is <em>no</em> performance penalty in using it instead of <a class="reference internal" href="#module-posix" title="posix: The most common POSIX system calls (normally used via module os). (Unix)"><code>posix</code></a>. In addition, <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> provides some additional functionality, such as automatically calling <a class="reference internal" href="os#os.putenv" title="os.putenv"><code>putenv()</code></a> when an entry in <code>os.environ</code> is changed.</p> <p>Errors are reported as exceptions; the usual exceptions are given for type errors, while errors reported by the system calls raise <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a>.</p> <section id="large-file-support"> <span id="posix-large-files"></span><h2>Large File Support</h2> <p id="index-1">Several operating systems (including AIX and Solaris) provide support for files that are larger than 2 GiB from a C programming model where <span class="c-expr sig sig-inline c"><span class="kt">int</span></span> and <span class="c-expr sig sig-inline c"><span class="kt">long</span></span> 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 <em class="dfn">large files</em>.</p> <p>Large file support is enabled in Python when the size of an <code>off_t</code> is larger than a <span class="c-expr sig sig-inline c"><span class="kt">long</span></span> and the <span class="c-expr sig sig-inline c"><span class="kt">long</span><span class="w"> </span><span class="kt">long</span></span> is at least as large as an <code>off_t</code>. It may be necessary to configure and compile Python with certain compiler flags to enable this mode. For example, with Solaris 2.6 and 2.7 you need to do something like:</p> <pre data-language="python">CFLAGS="`getconf LFS_CFLAGS`" OPT="-g -O2 $CFLAGS" \ + ./configure +</pre> <p>On large-file-capable Linux systems, this might work:</p> <pre data-language="python">CFLAGS='-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' OPT="-g -O2 $CFLAGS" \ + ./configure +</pre> </section> <section id="notable-module-contents"> <span id="posix-contents"></span><h2>Notable Module Contents</h2> <p>In addition to many functions described in the <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> module documentation, <a class="reference internal" href="#module-posix" title="posix: The most common POSIX system calls (normally used via module os). (Unix)"><code>posix</code></a> defines the following data item:</p> <dl class="py data"> <dt class="sig sig-object py" id="posix.environ"> +<code>posix.environ</code> </dt> <dd> +<p>A dictionary representing the string environment at the time the interpreter was started. Keys and values are bytes on Unix and str on Windows. For example, <code>environ[b'HOME']</code> (<code>environ['HOME']</code> on Windows) is the pathname of your home directory, equivalent to <code>getenv("HOME")</code> in C.</p> <p>Modifying this dictionary does not affect the string environment passed on by <a class="reference internal" href="os#os.execv" title="os.execv"><code>execv()</code></a>, <a class="reference internal" href="os#os.popen" title="os.popen"><code>popen()</code></a> or <a class="reference internal" href="os#os.system" title="os.system"><code>system()</code></a>; if you need to change the environment, pass <code>environ</code> to <a class="reference internal" href="os#os.execve" title="os.execve"><code>execve()</code></a> or add variable assignments and export statements to the command string for <a class="reference internal" href="os#os.system" title="os.system"><code>system()</code></a> or <a class="reference internal" href="os#os.popen" title="os.popen"><code>popen()</code></a>.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.2: </span>On Unix, keys and values are bytes.</p> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> module provides an alternate implementation of <code>environ</code> which updates the environment on modification. Note also that updating <a class="reference internal" href="os#os.environ" title="os.environ"><code>os.environ</code></a> will render this dictionary obsolete. Use of the <a class="reference internal" href="os#module-os" title="os: Miscellaneous operating system interfaces."><code>os</code></a> module version of this is recommended over direct access to the <a class="reference internal" href="#module-posix" title="posix: The most common POSIX system calls (normally used via module os). (Unix)"><code>posix</code></a> module.</p> </div> </dd> +</dl> </section> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/library/posix.html" class="_attribution-link">https://docs.python.org/3.12/library/posix.html</a> + </p> +</div> |
