17db96d56Sopenharmony_ci:mod:`posix` --- The most common POSIX system calls
27db96d56Sopenharmony_ci===================================================
37db96d56Sopenharmony_ci
47db96d56Sopenharmony_ci.. module:: posix
57db96d56Sopenharmony_ci   :platform: Unix
67db96d56Sopenharmony_ci   :synopsis: The most common POSIX system calls (normally used via module os).
77db96d56Sopenharmony_ci
87db96d56Sopenharmony_ci--------------
97db96d56Sopenharmony_ci
107db96d56Sopenharmony_ciThis module provides access to operating system functionality that is
117db96d56Sopenharmony_cistandardized by the C Standard and the POSIX standard (a thinly disguised Unix
127db96d56Sopenharmony_ciinterface).
137db96d56Sopenharmony_ci
147db96d56Sopenharmony_ci.. index:: pair: module; os
157db96d56Sopenharmony_ci
167db96d56Sopenharmony_ci**Do not import this module directly.**  Instead, import the module :mod:`os`,
177db96d56Sopenharmony_ciwhich provides a *portable* version of this interface.  On Unix, the :mod:`os`
187db96d56Sopenharmony_cimodule provides a superset of the :mod:`posix` interface.  On non-Unix operating
197db96d56Sopenharmony_cisystems the :mod:`posix` module is not available, but a subset is always
207db96d56Sopenharmony_ciavailable through the :mod:`os` interface.  Once :mod:`os` is imported, there is
217db96d56Sopenharmony_ci*no* performance penalty in using it instead of :mod:`posix`.  In addition,
227db96d56Sopenharmony_ci:mod:`os` provides some additional functionality, such as automatically calling
237db96d56Sopenharmony_ci:func:`~os.putenv` when an entry in ``os.environ`` is changed.
247db96d56Sopenharmony_ci
257db96d56Sopenharmony_ciErrors are reported as exceptions; the usual exceptions are given for type
267db96d56Sopenharmony_cierrors, while errors reported by the system calls raise :exc:`OSError`.
277db96d56Sopenharmony_ci
287db96d56Sopenharmony_ci
297db96d56Sopenharmony_ci.. _posix-large-files:
307db96d56Sopenharmony_ci
317db96d56Sopenharmony_ciLarge File Support
327db96d56Sopenharmony_ci------------------
337db96d56Sopenharmony_ci
347db96d56Sopenharmony_ci.. index::
357db96d56Sopenharmony_ci   single: large files
367db96d56Sopenharmony_ci   single: file; large files
377db96d56Sopenharmony_ci
387db96d56Sopenharmony_ci.. sectionauthor:: Steve Clift <clift@mail.anacapa.net>
397db96d56Sopenharmony_ci
407db96d56Sopenharmony_ciSeveral operating systems (including AIX and Solaris) provide
417db96d56Sopenharmony_cisupport for files that are larger than 2 GiB from a C programming model where
427db96d56Sopenharmony_ci:c:expr:`int` and :c:expr:`long` are 32-bit values. This is typically accomplished
437db96d56Sopenharmony_ciby defining the relevant size and offset types as 64-bit values. Such files are
447db96d56Sopenharmony_cisometimes referred to as :dfn:`large files`.
457db96d56Sopenharmony_ci
467db96d56Sopenharmony_ciLarge file support is enabled in Python when the size of an :c:type:`off_t` is
477db96d56Sopenharmony_cilarger than a :c:expr:`long` and the :c:expr:`long long` is at least as large
487db96d56Sopenharmony_cias an :c:type:`off_t`.
497db96d56Sopenharmony_ciIt may be necessary to configure and compile Python with certain compiler flags
507db96d56Sopenharmony_cito enable this mode. For example, with Solaris 2.6 and 2.7 you need to do
517db96d56Sopenharmony_cisomething like::
527db96d56Sopenharmony_ci
537db96d56Sopenharmony_ci   CFLAGS="`getconf LFS_CFLAGS`" OPT="-g -O2 $CFLAGS" \
547db96d56Sopenharmony_ci           ./configure
557db96d56Sopenharmony_ci
567db96d56Sopenharmony_ciOn large-file-capable Linux systems, this might work::
577db96d56Sopenharmony_ci
587db96d56Sopenharmony_ci   CFLAGS='-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' OPT="-g -O2 $CFLAGS" \
597db96d56Sopenharmony_ci           ./configure
607db96d56Sopenharmony_ci
617db96d56Sopenharmony_ci
627db96d56Sopenharmony_ci.. _posix-contents:
637db96d56Sopenharmony_ci
647db96d56Sopenharmony_ciNotable Module Contents
657db96d56Sopenharmony_ci-----------------------
667db96d56Sopenharmony_ci
677db96d56Sopenharmony_ciIn addition to many functions described in the :mod:`os` module documentation,
687db96d56Sopenharmony_ci:mod:`posix` defines the following data item:
697db96d56Sopenharmony_ci
707db96d56Sopenharmony_ci.. data:: environ
717db96d56Sopenharmony_ci
727db96d56Sopenharmony_ci   A dictionary representing the string environment at the time the interpreter
737db96d56Sopenharmony_ci   was started. Keys and values are bytes on Unix and str on Windows. For
747db96d56Sopenharmony_ci   example, ``environ[b'HOME']`` (``environ['HOME']`` on Windows) is the
757db96d56Sopenharmony_ci   pathname of your home directory, equivalent to ``getenv("HOME")`` in C.
767db96d56Sopenharmony_ci
777db96d56Sopenharmony_ci   Modifying this dictionary does not affect the string environment passed on by
787db96d56Sopenharmony_ci   :func:`~os.execv`, :func:`~os.popen` or :func:`~os.system`; if you need to
797db96d56Sopenharmony_ci   change the environment, pass ``environ`` to :func:`~os.execve` or add
807db96d56Sopenharmony_ci   variable assignments and export statements to the command string for
817db96d56Sopenharmony_ci   :func:`~os.system` or :func:`~os.popen`.
827db96d56Sopenharmony_ci
837db96d56Sopenharmony_ci   .. versionchanged:: 3.2
847db96d56Sopenharmony_ci      On Unix, keys and values are bytes.
857db96d56Sopenharmony_ci
867db96d56Sopenharmony_ci   .. note::
877db96d56Sopenharmony_ci
887db96d56Sopenharmony_ci      The :mod:`os` module provides an alternate implementation of ``environ``
897db96d56Sopenharmony_ci      which updates the environment on modification. Note also that updating
907db96d56Sopenharmony_ci      :data:`os.environ` will render this dictionary obsolete. Use of the
917db96d56Sopenharmony_ci      :mod:`os` module version of this is recommended over direct access to the
927db96d56Sopenharmony_ci      :mod:`posix` module.
93