Message383869
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. |
|
Date |
User |
Action |
Args |
2020-12-27 21:43:25 | vstinner | set | recipients:
+ vstinner, gregory.p.smith, benjamin.peterson, izbyshev |
2020-12-27 21:43:25 | vstinner | set | messageid: <1609105405.1.0.0419193676489.issue42736@roundup.psfhosted.org> |
2020-12-27 21:43:25 | vstinner | link | issue42736 messages |
2020-12-27 21:43:24 | vstinner | create | |
|