STINNER Victor <vstin...@python.org> added the comment:

sys.exit() accepts negative number and values larger than 255. I checked with 
strace: Python calls Linux exit_group() syscall with the value passed to 
sys.exit().

But then os.waitid() (waitid, not waitpid!) returns the lower 8-bits of the 
exit code.

In fact, the exit_group() syscall truncates the exit status:
https://github.com/torvalds/linux/blob/1a323ea5356edbb3073dc59d51b9e6b86908857d/kernel/exit.c#L895-L905

So on Linux, an exit code is always in the range [0; 255]. For example, 
exit_group(-1) syscall gives an exit code of 255.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40094>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to