From 979128fc4ad155c838bca3f7570470b723ffcc89 Mon Sep 17 00:00:00 2001 From: Andrew Tsai Date: Fri, 5 Sep 2025 16:48:13 +0800 Subject: [PATCH 1/2] docs: clarify returncode behavior for subprocess_exec vs subprocess_shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update asyncio.subprocess returncode documentation: - For create_subprocess_exec, negative values (-N) indicate termination by signal N (POSIX). - For create_subprocess_shell, the return code follows the invoked shell’s exit status (e.g. 128+N for signals in bash/sh). --- Doc/library/asyncio-subprocess.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 03e76bc868905e..d71ae6170a06d1 100644 --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -305,8 +305,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: From 459055846a01b8221f162fe727dc8ecaef578a25 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Sat, 21 Mar 2026 17:42:28 +0530 Subject: [PATCH 2/2] Add note subprocess as well --- Doc/library/subprocess.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 028a7861f36798..7f72db8ba77a06 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -945,6 +945,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 ---------------------