WEXITSTATUS without checking WIFEXITED
Closed this issue · 3 comments
msavage20 commented
From waitpid(2):
WEXITSTATUS(status)
returns the exit status of the child. [...] This macro should only be employed if WIFEXITED returned true.
dumb-init does not check WIFEXITED before calling WEXITSTATUS, which could lead to funny behaviour when the child process is terminated by a signal.
chriskuehl commented
@msavage20 thanks for the report!
here's the non-dumb-init behavior:
ckuehl@dev18-devc:~$ python -c 'while True: pass'
[in another terminal, send SIGTERM to python]
ckuehl@dev18-devc:~$ echo $?
143
and the dumb-init behavior:
ckuehl@dev18-devc:~$ dumb-init python -c 'while True: pass'
[in another terminal, send SIGTERM to python]
ckuehl@dev18-devc:~$ echo $?
0
I'll start preparing a patch.
bukzor commented
I don't know much about this corner of posix/C, but the logic looks good.
chriskuehl commented
fix released in v1.0.1, thanks again for the report!