STINNER Victor <[email protected]> added the comment:
I agree that it would be nice to pack these parameters, similar to the Windows
STARTUPINFO. The subprocess.Popen constructor has more and more parameter for
functions executed between fork and exec:
def __init__(self, args, bufsize=-1, executable=None,
stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=True,
shell=False, cwd=None, env=None, universal_newlines=None,
startupinfo=None, creationflags=0,
restore_signals=True, start_new_session=False,
pass_fds=(), *, user=None, group=None, extra_groups=None,
encoding=None, errors=None, text=None, umask=-1, pipesize=-1):
Parameters:
* close_fds: close()
* pass_fds: _Py_set_inheritable_async_safe()
* restore_signals: _Py_RestoreSignals()
* start_new_session: setsid()
* user: setreuid()
* group: setregid()
* extra_groups: setgroups()
* cwd: chdir()
* umask: umask()
* XXX special case: preexec_fn.
Idea of API:
-------------
preexec = subprocess.Preexec()
preexec.setsid()
preexec.chdir(path)
popen = subprocess.Popen(cmd, preexec=preexec)
popen.wait()
-------------
It would make error reporting more helpful. For example, if the path type is
not bytes or str, preexec.chdir(path) call would raise an error, rather than
getting an error in the complex Popen constructor.
----------
nosy: +vstinner
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42736>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com