diff options
author | Gregory P. Smith <greg@krypto.org> | 2022-05-05 23:22:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 23:22:32 (GMT) |
commit | f6dd14c65336cda4e2ebccbc6408dfe3b0a68a34 (patch) | |
tree | 75e0b51fc5787a7ba02cf1f0534b292fb9a0a528 /Doc | |
parent | 49fda0cc51c09e26d68431d5f86e11d923cf7b8e (diff) | |
download | cpython-f6dd14c65336cda4e2ebccbc6408dfe3b0a68a34.zip cpython-f6dd14c65336cda4e2ebccbc6408dfe3b0a68a34.tar.gz cpython-f6dd14c65336cda4e2ebccbc6408dfe3b0a68a34.tar.bz2 |
gh-82616: Add process_group support to subprocess.Popen (#23930)
One more thing that can help prevent people from using `preexec_fn`.
Also adds conditional skips to two tests exposing ASAN flakiness on the Ubuntu 20.04 Address Sanitizer Github CI system. When that build is run on more modern systems the "problem" does not show up. It seems ASAN implementation related.
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/subprocess.rst | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 1e619a5..ce581ab 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -344,7 +344,8 @@ functions. startupinfo=None, creationflags=0, restore_signals=True, \ start_new_session=False, pass_fds=(), *, group=None, \ extra_groups=None, user=None, umask=-1, \ - encoding=None, errors=None, text=None, pipesize=-1) + encoding=None, errors=None, text=None, pipesize=-1, \ + process_group=None) Execute a child program in a new process. On POSIX, the class uses :meth:`os.execvpe`-like behavior to execute the child program. On Windows, @@ -500,18 +501,16 @@ functions. .. warning:: - The *preexec_fn* parameter is not safe to use in the presence of threads + The *preexec_fn* parameter is NOT SAFE to use in the presence of threads in your application. The child process could deadlock before exec is called. - If you must use it, keep it trivial! Minimize the number of libraries - you call into. .. note:: If you need to modify the environment for the child use the *env* parameter rather than doing it in a *preexec_fn*. - The *start_new_session* parameter can take the place of a previously - common use of *preexec_fn* to call os.setsid() in the child. + The *start_new_session* and *process_group* parameters should take the place of + code using *preexec_fn* to call :func:`os.setsid` or :func:`os.setpgid` in the child. .. versionchanged:: 3.8 @@ -568,12 +567,20 @@ functions. .. versionchanged:: 3.2 *restore_signals* was added. - If *start_new_session* is true the setsid() system call will be made in the - child process prior to the execution of the subprocess. (POSIX only) + If *start_new_session* is true the ``setsid()`` system call will be made in the + child process prior to the execution of the subprocess. + .. availability:: POSIX .. versionchanged:: 3.2 *start_new_session* was added. + If *process_group* is a non-negative integer, the ``setpgid(0, value)`` system call will + be made in the child process prior to the execution of the subprocess. + + .. availability:: POSIX + .. versionchanged:: 3.11 + *process_group* was added. + If *group* is not ``None``, the setregid() system call will be made in the child process prior to the execution of the subprocess. If the provided value is a string, it will be looked up via :func:`grp.getgrnam()` and |