Message365495
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. |
|
| Date |
User |
Action |
Args |
| 2020-04-01 16:54:17 | vstinner | set | recipients:
+ vstinner, eryksun, miss-islington |
| 2020-04-01 16:54:17 | vstinner | set | messageid: <1585760057.07.0.82863037692.issue40094@roundup.psfhosted.org> |
| 2020-04-01 16:54:17 | vstinner | link | issue40094 messages |
| 2020-04-01 16:54:16 | vstinner | create | |
|