Skip to content

Commit e57cf1c

Browse files
miss-islingtonraixyzadityavstinner
authored
[3.13] gh-142302: Fix mkstemp() documentation: clarify file descriptor inheritance behavior (GH-142338) (#143487)
gh-142302: Fix mkstemp() documentation: clarify file descriptor inheritance behavior (GH-142338) The documentation incorrectly stated that the file descriptor is not inherited by child processes. In reality, the close-on-exec flag (when available) only prevents inheritance across exec() calls, not fork(). (cherry picked from commit e79c9b7) Co-authored-by: ADITYA RAI <adi.hack1234@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent f7711d5 commit e57cf1c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Doc/library/os.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,8 @@ can be inherited by child processes. Since Python 3.4, file descriptors
18891889
created by Python are non-inheritable by default.
18901890

18911891
On UNIX, non-inheritable file descriptors are closed in child processes at the
1892-
execution of a new program, other file descriptors are inherited.
1892+
execution of a new program, other file descriptors are inherited. Note that
1893+
non-inheritable file descriptors are still *inherited* by child processes on :func:`os.fork`.
18931894

18941895
On Windows, non-inheritable handles and file descriptors are closed in child
18951896
processes, except for standard streams (file descriptors 0, 1 and 2: stdin, stdout

Doc/library/tempfile.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ The module defines the following user-callable items:
225225
properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The
226226
file is readable and writable only by the creating user ID. If the
227227
platform uses permission bits to indicate whether a file is executable,
228-
the file is executable by no one. The file descriptor is not inherited
229-
by child processes.
228+
the file is executable by no one.
229+
230+
The file descriptor is :ref:`not inherited by child processes <fd_inheritance>`.
230231

231232
Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible
232233
for deleting the temporary file when done with it.

0 commit comments

Comments
 (0)