From: Victor Stinner Date: Tue, 29 Sep 2015 11:59:50 +0000 (+0200) Subject: Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat() X-Git-Tag: v3.6.0a1~1401 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=449b27179931aa570597556ed4865ac2f1f981c9;p=thirdparty%2FPython%2Fcpython.git Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat() --- diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 4f5efc963c77..857a543cf546 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -972,6 +972,9 @@ is_valid_fd(int fd) 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);