From: Ross Lagerwall Date: Mon, 19 Mar 2012 04:08:43 +0000 (+0200) Subject: Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined. X-Git-Tag: v3.3.0a2~109^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71faefc37e4a74d72e9a56243a085bfddd9209e0;p=thirdparty%2FPython%2Fcpython.git Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined. Based on patch from Hervé Coatanhay. --- diff --git a/Misc/ACKS b/Misc/ACKS index 2b3dad5424fc..77cec5c645eb 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -173,6 +173,7 @@ Mike Clarkson Andrew Clegg Brad Clements Steve Clift +Hervé Coatanhay Nick Coghlan Josh Cogliati Dave Cole diff --git a/Misc/NEWS b/Misc/NEWS index b1a60d37d2ea..40b17fc87f6b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -78,6 +78,12 @@ Extension Modules - 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 index d520c8c7692e..81274e12c8ba 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -202,7 +202,18 @@ _close_open_fd_range_safe(int start_fd, int end_fd, PyObject* py_fds_to_keep) 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);