[Python-checkins] cpython (3.2): Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined.

ross.lagerwall python-checkins at python.org
Mon Mar 19 05:13:54 CET 2012


http://hg.python.org/cpython/rev/09371e2ae84d
changeset:   75834:09371e2ae84d
branch:      3.2
parent:      75827:66e2dab98041
user:        Ross Lagerwall <rosslagerwall at gmail.com>
date:        Mon Mar 19 06:08:43 2012 +0200
summary:
  Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined.

Based on patch from Hervé Coatanhay.

files:
  Misc/ACKS                  |   1 +
  Misc/NEWS                  |   6 ++++++
  Modules/_posixsubprocess.c |  13 ++++++++++++-
  3 files changed, 19 insertions(+), 1 deletions(-)


diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -173,6 +173,7 @@
 Andrew Clegg
 Brad Clements
 Steve Clift
+Hervé Coatanhay
 Nick Coghlan
 Josh Cogliati
 Dave Cole
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -78,6 +78,12 @@
 - Issue #14212: The re module didn't retain a reference to buffers it was
   scanning, resulting in segfaults.
 
+Build
+-----
+
+- Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined.
+  Based on patch from Hervé Coatanhay.
+
 
 What's New in Python 3.2.3 release candidate 2?
 ===============================================
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -202,7 +202,18 @@
     int fd_dir_fd;
     if (start_fd >= end_fd)
         return;
-        fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0);
+#ifdef O_CLOEXEC
+    fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0);
+#else
+    fd_dir_fd = open(FD_DIR, O_RDONLY, 0);
+#ifdef FD_CLOEXEC
+    {
+        int old = fcntl(fd_dir_fd, F_GETFD);
+        if (old != -1)
+            fcntl(fd_dir_fd, F_SETFD, old | FD_CLOEXEC);
+    }
+#endif
+#endif
     if (fd_dir_fd == -1) {
         /* No way to get a list of open fds. */
         _close_fds_by_brute_force(start_fd, end_fd, py_fds_to_keep);

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


More information about the Python-checkins mailing list