Skip to content

Commit 660a89a

Browse files
committed
Fix mkstemp() documentation regarding fd inheritance
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(). The fd will still be inherited by forked child processes.
1 parent d119443 commit 660a89a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Doc/library/tempfile.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ 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. On platforms that support the :const:
229+
`os.O_CLOEXEC` flag, the file descriptor has the close-on-exec flag set,
230+
which prevents it from being inherited across :func:`os.exec*` calls.
231+
However, the file descriptor will still be inherited by child processes created via :func:`os.fork`.
230232

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

0 commit comments

Comments
 (0)