Commit 449b2717 authored by Victor Stinner's avatar Victor Stinner

Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat()

parent 3f746850
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment