Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEXITSTATUS without checking WIFEXITED #59

Closed
msavage20 opened this issue Mar 11, 2016 · 3 comments
Closed

WEXITSTATUS without checking WIFEXITED #59

msavage20 opened this issue Mar 11, 2016 · 3 comments
Labels

Comments

@msavage20
Copy link

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
Copy link
Contributor

@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
Copy link
Contributor

bukzor commented Mar 11, 2016

I don't know much about this corner of posix/C, but the logic looks good.

:shipit:

@chriskuehl
Copy link
Contributor

fix released in v1.0.1, thanks again for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants