Skip to content

Commit 8a531f8

Browse files
gh-138234: clarify returncode behavior for subprocesses created with shell=True (#138536)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
1 parent 60fbc20 commit 8a531f8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Doc/library/asyncio-subprocess.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,16 @@ their completion.
311311

312312
A ``None`` value indicates that the process has not terminated yet.
313313

314-
A negative value ``-N`` indicates that the child was terminated
315-
by signal ``N`` (POSIX only).
314+
For processes created with :func:`~asyncio.create_subprocess_exec`, a negative
315+
value ``-N`` indicates that the child was terminated by signal ``N``
316+
(POSIX only).
317+
318+
For processes created with :func:`~asyncio.create_subprocess_shell`, the
319+
return code reflects the exit status of the shell itself (e.g. ``/bin/sh``),
320+
which may map signals to codes such as ``128+N``. See the
321+
documentation of the shell (for example, the Bash manual's Exit Status)
322+
for details.
323+
316324

317325

318326
.. _asyncio-subprocess-threads:

Doc/library/subprocess.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ Reassigning them to new values is unsupported:
964964
A negative value ``-N`` indicates that the child was terminated by signal
965965
``N`` (POSIX only).
966966

967+
When ``shell=True``, the return code reflects the exit status of the shell
968+
itself (e.g. ``/bin/sh``), which may map signals to codes such as
969+
``128+N``. See the documentation of the shell (for example, the Bash
970+
manual's Exit Status) for details.
971+
967972

968973
Windows Popen Helpers
969974
---------------------

0 commit comments

Comments
 (0)