summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-01 16:49:29 (GMT)
committerGitHub <noreply@github.com>2020-04-01 16:49:29 (GMT)
commit65a796e5272f61b42792d3a8c69686558c1872c5 (patch)
tree138d64a8dd04ab4d1cac2eb5c415aa10e0bbe00f /Lib/os.py
parent5dd836030e0e399b21ab0865ae0d93934bdb3930 (diff)
downloadcpython-65a796e5272f61b42792d3a8c69686558c1872c5.zip
cpython-65a796e5272f61b42792d3a8c69686558c1872c5.tar.gz
cpython-65a796e5272f61b42792d3a8c69686558c1872c5.tar.bz2
bpo-40094: Add os.waitstatus_to_exitcode() (GH-19201)
Add os.waitstatus_to_exitcode() function to convert a wait status to an exitcode. Suggest waitstatus_to_exitcode() usage in the documentation when appropriate. Use waitstatus_to_exitcode() in: * multiprocessing, os, subprocess and _bootsubprocess modules; * test.support.wait_process(); * setup.py: run_command(); * and many tests.
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 8459baa..8acd6f1 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -864,12 +864,8 @@ if _exists("fork") and not _exists("spawnv") and _exists("execv"):
wpid, sts = waitpid(pid, 0)
if WIFSTOPPED(sts):
continue
- elif WIFSIGNALED(sts):
- return -WTERMSIG(sts)
- elif WIFEXITED(sts):
- return WEXITSTATUS(sts)
- else:
- raise OSError("Not stopped, signaled or exited???")
+
+ return waitstatus_to_exitcode(sts)
def spawnv(mode, file, args):
"""spawnv(mode, file, args) -> integer