This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients benjamin.peterson, gregory.p.smith, izbyshev, vstinner
Date 2020-12-27.21:43:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609105405.1.0.0419193676489.issue42736@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-12-27 21:43:25vstinnersetrecipients: + vstinner, gregory.p.smith, benjamin.peterson, izbyshev
2020-12-27 21:43:25vstinnersetmessageid: <1609105405.1.0.0419193676489.issue42736@roundup.psfhosted.org>
2020-12-27 21:43:25vstinnerlinkissue42736 messages
2020-12-27 21:43:24vstinnercreate