Issue #18763: subprocess: The file descriptors are now closed after calling the
preexec_fn callback, which may open file descriptors.
This commit is contained in:
parent
59a06f5020
commit
4c53314475
|
@ -1247,16 +1247,17 @@ class Popen(object):
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
closed.add(fd)
|
closed.add(fd)
|
||||||
|
|
||||||
# Close all other fds, if asked for
|
|
||||||
if close_fds:
|
|
||||||
self._close_fds(but=errpipe_write)
|
|
||||||
|
|
||||||
if cwd is not None:
|
if cwd is not None:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
if preexec_fn:
|
if preexec_fn:
|
||||||
preexec_fn()
|
preexec_fn()
|
||||||
|
|
||||||
|
# Close all other fds, if asked for - after
|
||||||
|
# preexec_fn(), which may open FDs.
|
||||||
|
if close_fds:
|
||||||
|
self._close_fds(but=errpipe_write)
|
||||||
|
|
||||||
if env is None:
|
if env is None:
|
||||||
os.execvp(executable, args)
|
os.execvp(executable, args)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue