[Python-checkins] cpython: Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat()
victor.stinner
python-checkins at python.org
Tue Sep 29 14:00:14 CEST 2015
https://hg.python.org/cpython/rev/0e7d71a3bf0d
changeset: 98382:0e7d71a3bf0d
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Sep 29 13:59:50 2015 +0200
summary:
Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat()
files:
Python/pylifecycle.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -972,6 +972,9 @@
if (fd < 0 || !_PyVerify_fd(fd))
return 0;
_Py_BEGIN_SUPPRESS_IPH
+ /* Prefer dup() over fstat(). fstat() can require input/output whereas
+ dup() doesn't, there is a low risk of EMFILE/ENFILE at Python
+ startup. */
fd2 = dup(fd);
if (fd2 >= 0)
close(fd2);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list