Skip to content

Commit 220c5d0

Browse files
committed
Simplify mkstemp() fd inheritance documentataion. Based on code review , O_CLOEXEC is not included in the flags used by mkstemp(). The fd will be inherited by all child processes. Thanks to @QuiteAFoxtrot for the investigation
1 parent 6cba2c6 commit 220c5d0

File tree

2 files changed

+485
-13
lines changed

2 files changed

+485
-13
lines changed

Doc/library/tempfile.rst

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,14 @@ The module defines the following user-callable items:
220220

221221
.. function:: mkstemp(suffix=None, prefix=None, dir=None, text=False)
222222

223-
Creates a temporary file in the most secure manner possible. There are
224-
no race conditions in the file's creation, assuming that the platform
225-
properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The
226-
file is readable and writable only by the creating user ID. If the
227-
platform uses permission bits to indicate whether a file is executable,
228-
the file is executable by no one.
229-
230-
On platforms that support the :const:`os.O_CLOEXEC` flag, the file
231-
descriptor is created with the close-on-exec flag set. This prevents it
232-
from being inherited across ``exec*``-style calls that replace the current
233-
process image. However, the file descriptor will still be inherited by
234-
child processes created via :func:`os.fork`.
235-
223+
Creates a temporary file in the most secure manner possible. There are
224+
no race conditions in the file's creation, assuming that the platform
225+
properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The
226+
file is readable and writable only by the creating user ID. If the
227+
platform uses permission bits to indicate whether a file is executable,
228+
the file is executable by no one.
229+
230+
The file descriptor will be inherited by child processes.
236231

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

0 commit comments

Comments
 (0)