-
Notifications
You must be signed in to change notification settings - Fork 0
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
Grandchild processes ignoring SIGTERM are not killed #2
Comments
Sounds like this could be similar to what I'm seeing happen with vite on a Rails project. After hitting Ctrl C, the other items from my Procfile terminal, but vite takes up to 30s(?) to terminate, but if I run the command natively ( |
Not sure if this is the same issue. Could it be that Vite handles SIGTERM and SIGINT differently? If you run Vite natively, on Ctrl-C, its process receives SIGINT. If you run Vite through Foreman/Overman, Vite process receives SIGTERM. |
@oleg-vinted Re: ddollar#780 (comment), does the other foreman variants handle what you have reported here? If so, how do they do it? |
The other variants work fine, and as far as I remember (haven't looked into this since July, please double check) they wait for the stdout pipe to be closed on the child process's end, and this indicates to the process manager that all the subprocesses have exited. In other words, it waits for both (1) immediate child PID to exit, (2) the stdout pipe to close on the other end. (1) can occur before (2), and (2) is the missing part in |
Maybe use https://github.com/enkessler/childprocess? Or look at it for inspiration (thinking of enkessler/childprocess#175) |
Repro: https://gist.github.com/oleg-vinted/97ee727e8d0b1050f40fc3ec9f940281
Even with the process group change, in some cases processes can still be orphaned.
In that repro, we have:
overman -> service -> stubborn-process -> sleep
process hierarchy.What I think is happening:
overman
, because its children are running in a different process group.service
,stubborn-process
,sleep
.service
andsleep
terminate upon receiving SIGTERM.stubborn-process
ignores SIGTERM and spawns another instance ofsleep
and keeps running.overman
sees that its immediate child (service
) has exited and removes its PID from the running list: through here, here and here.overman
thinks its children have exited,so it does not send SIGKILL to the process group, even though SIGKILL is still necessary because(Edit: not true, sending a SIGKILL to the process group doesn't work at this point. We need some other way to detect if children have exited.)stubborn-process
is still runningThe text was updated successfully, but these errors were encountered: