diff options
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index b94575b..d63cf20 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -655,6 +655,7 @@ def _use_posix_spawn(): _USE_POSIX_SPAWN = _use_posix_spawn() +_HAVE_POSIX_SPAWNP = hasattr(os, 'posix_spawnp') class Popen(object): @@ -1442,7 +1443,10 @@ class Popen(object): def _posix_spawn(self, args, executable, env, restore_signals): - """Execute program using os.posix_spawn().""" + """Execute program using os.posix_spawnp(). + + Or use os.posix_spawn() if os.posix_spawnp() is not available. + """ if env is None: env = os.environ @@ -1456,7 +1460,10 @@ class Popen(object): sigset.append(signum) kwargs['setsigdef'] = sigset - self.pid = os.posix_spawn(executable, args, env, **kwargs) + if _HAVE_POSIX_SPAWNP: + self.pid = os.posix_spawnp(executable, args, env, **kwargs) + else: + self.pid = os.posix_spawn(executable, args, env, **kwargs) def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, @@ -1484,7 +1491,7 @@ class Popen(object): executable = args[0] if (_USE_POSIX_SPAWN - and os.path.dirname(executable) + and (_HAVE_POSIX_SPAWNP or os.path.dirname(executable)) and preexec_fn is None and not close_fds and not pass_fds |