From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 21 Mar 2026 12:38:34 +0000 (+0100) Subject: [3.14] gh-138234: clarify returncode behavior for subprocesses created with `shell... X-Git-Tag: v3.14.4~97 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f2c70247fb2a3a0d416fc9221a16d9cae3926b8d;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-138234: clarify returncode behavior for subprocesses created with `shell=True` (GH-138536) (#146254) gh-138234: clarify returncode behavior for subprocesses created with `shell=True` (GH-138536) (cherry picked from commit 8a531f89df8f8bf4c4fe395f9edcdc19852bdf1c) Co-authored-by: andreuu-tsai <32549555+andreuu-tsai@users.noreply.github.com> Co-authored-by: Kumar Aditya --- diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 9416c758e51d..cb9ddc08a64d 100644 --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -311,8 +311,16 @@ their completion. A ``None`` value indicates that the process has not terminated yet. - A negative value ``-N`` indicates that the child was terminated - by signal ``N`` (POSIX only). + For processes created with :func:`~asyncio.create_subprocess_exec`, a negative + value ``-N`` indicates that the child was terminated by signal ``N`` + (POSIX only). + + For processes created with :func:`~asyncio.create_subprocess_shell`, the + return code reflects the exit status of the shell itself (e.g. ``/bin/sh``), + which may map signals to codes such as ``128+N``. See the + documentation of the shell (for example, the Bash manual's Exit Status) + for details. + .. _asyncio-subprocess-threads: diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index a0eae14aecdd..82e41bff8797 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -952,6 +952,11 @@ Reassigning them to new values is unsupported: A negative value ``-N`` indicates that the child was terminated by signal ``N`` (POSIX only). + When ``shell=True``, the return code reflects the exit status of the shell + itself (e.g. ``/bin/sh``), which may map signals to codes such as + ``128+N``. See the documentation of the shell (for example, the Bash + manual's Exit Status) for details. + Windows Popen Helpers ---------------------