changeset: 98382:0e7d71a3bf0d user: Victor Stinner date: Tue Sep 29 13:59:50 2015 +0200 files: Python/pylifecycle.c description: Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat() diff -r 9afc4aca1237 -r 0e7d71a3bf0d Python/pylifecycle.c --- a/Python/pylifecycle.c Tue Sep 29 13:47:15 2015 +0200 +++ b/Python/pylifecycle.c Tue Sep 29 13:59:50 2015 +0200 @@ -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);