]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18174: Explain why is_valid_fd() uses dup() instead of fstat()
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Sep 2015 11:59:50 +0000 (13:59 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Sep 2015 11:59:50 +0000 (13:59 +0200)
Python/pylifecycle.c

index 4f5efc963c7722b2be204c328a06bc9d47adb11b..857a543cf546bc4c8d1ff29cff7ccc0b7b9b1b50 100644 (file)
@@ -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);