[Python-checkins] cpython: Issue #23694: Fix usage of _Py_open() in the _posixsubprocess module

victor.stinner python-checkins at python.org
Mon Mar 30 02:20:57 CEST 2015


https://hg.python.org/cpython/rev/2e1234208bab
changeset:   95265:2e1234208bab
parent:      95261:6bae19f4e7b2
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Mar 30 02:18:31 2015 +0200
summary:
  Issue #23694: Fix usage of _Py_open() in the _posixsubprocess module

Don't call _Py_open() from _close_open_fds_safe() because it is call just after
fork(). It's not good to play with locks (the GIL) between fork() and exec().

Use instead _Py_open_noraise() which doesn't touch to the GIL.

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


diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -254,10 +254,9 @@
 {
     int fd_dir_fd;
 
-    fd_dir_fd = _Py_open(FD_DIR, O_RDONLY);
+    fd_dir_fd = _Py_open_noraise(FD_DIR, O_RDONLY);
     if (fd_dir_fd == -1) {
         /* No way to get a list of open fds. */
-        PyErr_Clear();
         _close_fds_by_brute_force(start_fd, py_fds_to_keep);
         return;
     } else {

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


More information about the Python-checkins mailing list