mirror of
https://github.com/python/cpython.git
synced 2025-09-20 15:40:32 +00:00
Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat()
This commit is contained in:
parent
3f7468507a
commit
449b271799
1 changed files with 3 additions and 0 deletions
|
@ -972,6 +972,9 @@ is_valid_fd(int fd)
|
||||||
if (fd < 0 || !_PyVerify_fd(fd))
|
if (fd < 0 || !_PyVerify_fd(fd))
|
||||||
return 0;
|
return 0;
|
||||||
_Py_BEGIN_SUPPRESS_IPH
|
_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);
|
fd2 = dup(fd);
|
||||||
if (fd2 >= 0)
|
if (fd2 >= 0)
|
||||||
close(fd2);
|
close(fd2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue