Message377012
The return code of python on linux when the program is ended with a KeyboardInterrupt should be -2, this works in most cases - except when called via "python -m"
Does this repl help?
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib, subprocess
>>> pathlib.Path("spam.py").write_text("raise KeyboardInterrupt")
23
>>> subprocess.run(["python3", "spam.py"])
Traceback (most recent call last):
File "spam.py", line 1, in <module>
raise KeyboardInterrupt
KeyboardInterrupt
CompletedProcess(args=['python3', 'spam.py'], returncode=-2)
>>> subprocess.run(["python3", "-m", "spam"])
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/graingert/projects/spam.py", line 1, in <module>
raise KeyboardInterrupt
KeyboardInterrupt
CompletedProcess(args=['python3', '-m', 'spam'], returncode=1)
>>> |
|
Date |
User |
Action |
Args |
2020-09-16 19:08:56 | graingert | set | recipients:
+ graingert, gvanrossum, gregory.p.smith, ncoghlan |
2020-09-16 19:08:56 | graingert | set | messageid: <1600283336.31.0.962711371894.issue41602@roundup.psfhosted.org> |
2020-09-16 19:08:56 | graingert | link | issue41602 messages |
2020-09-16 19:08:56 | graingert | create | |
|