[Python-checkins] cpython (3.4): Issue #23851: close() must not be retried when it fails with EINTR

victor.stinner python-checkins at python.org
Thu Apr 2 16:26:30 CEST 2015


https://hg.python.org/cpython/rev/e54b23d7afa6
changeset:   95384:e54b23d7afa6
branch:      3.4
parent:      95379:dafae2b3c257
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Apr 02 16:24:46 2015 +0200
summary:
  Issue #23851: close() must not be retried when it fails with EINTR

See the PEP 475 for the rationale.

files:
  Modules/_posixsubprocess.c |  12 ++++++------
  1 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -207,13 +207,13 @@
         if (keep_fd < start_fd)
             continue;
         for (fd_num = start_fd; fd_num < keep_fd; ++fd_num) {
-            while (close(fd_num) < 0 && errno == EINTR);
+            close(fd_num);
         }
         start_fd = keep_fd + 1;
     }
     if (start_fd <= end_fd) {
         for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
-            while (close(fd_num) < 0 && errno == EINTR);
+            close(fd_num);
         }
     }
 }
@@ -274,11 +274,11 @@
                     continue;  /* Not a number. */
                 if (fd != fd_dir_fd && fd >= start_fd &&
                     !_is_fd_in_sorted_fd_sequence(fd, py_fds_to_keep)) {
-                    while (close(fd) < 0 && errno == EINTR);
+                    close(fd);
                 }
             }
         }
-        while (close(fd_dir_fd) < 0 && errno == EINTR);
+        close(fd_dir_fd);
     }
 }
 
@@ -312,7 +312,7 @@
      * reuse that fd otherwise we might close opendir's file descriptor in
      * our loop.  This trick assumes that fd's are allocated on a lowest
      * available basis. */
-    while (close(start_fd) < 0 && errno == EINTR);
+    close(start_fd);
     ++start_fd;
 #endif
 
@@ -339,7 +339,7 @@
                 continue;  /* Not a number. */
             if (fd != fd_used_by_opendir && fd >= start_fd &&
                 !_is_fd_in_sorted_fd_sequence(fd, py_fds_to_keep)) {
-                while (close(fd) < 0 && errno == EINTR);
+                close(fd);
             }
             errno = 0;
         }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list