Mercurial > cpython-lru_cache-weakref
diff Modules/_posixsubprocess.c @ 75834:09371e2ae84d 3.2
Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined.
Based on patch from Hervé Coatanhay.
| author | Ross Lagerwall <rosslagerwall@gmail.com> |
|---|---|
| date | Mon, 19 Mar 2012 06:08:43 +0200 |
| parents | 308f4af9548e |
| children | aa9cfeea07ad 0d5fcbfd646f |
line wrap: on
line diff
--- a/Modules/_posixsubprocess.c Sun Mar 18 20:50:03 2012 -0400 +++ b/Modules/_posixsubprocess.c Mon Mar 19 06:08:43 2012 +0200 @@ -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);
