Author vstinner
Recipients eryksun, miss-islington, vstinner
Date 2020-04-01.16:54:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585760057.07.0.82863037692.issue40094@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-04-01 16:54:17vstinnersetrecipients: + vstinner, eryksun, miss-islington
2020-04-01 16:54:17vstinnersetmessageid: <1585760057.07.0.82863037692.issue40094@roundup.psfhosted.org>
2020-04-01 16:54:17vstinnerlinkissue40094 messages
2020-04-01 16:54:16vstinnercreate