summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-12-07 20:35:43 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-12-07 20:35:43 (GMT)
commit25059d30c39c0c703161987643f0c29df03147fb (patch)
treede22166aa881073d0d001153d3d7dd45046db067 /Modules
parent2f09812efa0701721825b17086de3631462039a6 (diff)
downloadcpython-25059d30c39c0c703161987643f0c29df03147fb.zip
cpython-25059d30c39c0c703161987643f0c29df03147fb.tar.gz
cpython-25059d30c39c0c703161987643f0c29df03147fb.tar.bz2
SF patch #489173: Make os.spawnv not block the interpreter, from
Anthony Roach. Release the global interpreter lock around platform spawn calls. Bugfix candidate? Hard to say; I favor "yes, bugfix". These clearly *should* have been releasing the GIL all along, if for no other reason than compatibility with the similar os.system(). But it's possible some program out there is (a) multithreaded, (b) calling a spawn function with P_WAIT, and (c) relying on the spawn call to block all their threads until the spawned program completes. I think it's very unlikely anyone is doing that on purpose, but someone may be doing so by accident.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index bb55762..ebda8bf 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1668,7 +1668,7 @@ posix_execve(PyObject *self, PyObject *args)
#ifdef HAVE_SPAWNV
static char posix_spawnv__doc__[] =
"spawnv(mode, path, args)\n\
-Execute an executable path with arguments, replacing current process.\n\
+Execute the program 'path' in a new process.\n\
\n\
mode: mode of process creation\n\
path: path of executable file\n\
@@ -1717,8 +1717,11 @@ posix_spawnv(PyObject *self, PyObject *args)
if (mode == _OLD_P_OVERLAY)
mode = _P_OVERLAY;
+
+ Py_BEGIN_ALLOW_THREADS
spawnval = _spawnv(mode, path, argvlist);
-
+ Py_END_ALLOW_THREADS
+
PyMem_DEL(argvlist);
if (spawnval == -1)
@@ -1734,7 +1737,7 @@ posix_spawnv(PyObject *self, PyObject *args)
static char posix_spawnve__doc__[] =
"spawnve(mode, path, args, env)\n\
-Execute a path with arguments and environment, replacing current process.\n\
+Execute the program 'path' in a new process.\n\
\n\
mode: mode of process creation\n\
path: path of executable file\n\
@@ -1830,7 +1833,11 @@ posix_spawnve(PyObject *self, PyObject *args)
if (mode == _OLD_P_OVERLAY)
mode = _P_OVERLAY;
+
+ Py_BEGIN_ALLOW_THREADS
spawnval = _spawnve(mode, path, argvlist, envlist);
+ Py_END_ALLOW_THREADS
+
if (spawnval == -1)
(void) posix_error();
else