]> granicus.if.org Git - python/commitdiff
Issue #23694: Fix usage of _Py_open() in the _posixsubprocess module
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 00:18:31 +0000 (02:18 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 00:18:31 +0000 (02:18 +0200)
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.

Modules/_posixsubprocess.c

index a33df211e980eaa8079896333b67593add009443..0b385a1ab151bb04c17d92cd8917ce80de8901fa 100644 (file)
@@ -254,10 +254,9 @@ _close_open_fds_safe(int start_fd, PyObject* py_fds_to_keep)
 {
     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 {