You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Racing a, b, and sleep10s should terminate a and b when sleep 10 exits after 10 seconds but instead run-p hangs:
$ ./node_modules/.bin/run-p --race a b sleep10s
> example@1.0.0 a /Users/jim/example
> test/programs/a
> example@1.0.0 b /Users/jim/example
> test/programs/b
> example@1.0.0 sleep10s /Users/jim/example
> sleep 10
GRACEFUL
IGNORING SIGNAL
This is because b doesn't correctly handle SIGTERM and needs to be sent SIGKILL.
Racing tasks that do correctly respond to SIGTERM works fine:
$ ./node_modules/.bin/run-p --race a a a sleep10s
> example@1.0.0 sleep10s /Users/jim/example
> sleep 10
> example@1.0.0 a /Users/jim/example
> test/programs/a
> example@1.0.0 a /Users/jim/example
> test/programs/a
> example@1.0.0 a /Users/jim/example
> test/programs/a
GRACEFUL
GRACEFUL
GRACEFUL
What's worse is that further sending SIGINT to run-p will cause it to exit (with 130) and orphan b. The process tree while hanging:
-+= 74470 jim node ./node_modules/.bin/run-p --race a a a b sleep10s
\-+- 74474 jim npm
\--- 74480 jim /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u test/programs/b
The process tree after SIGINT:
-+= 00001 root /sbin/launchd
\-+- 74474 jim npm
\--- 74480 jim /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u test/programs/b
Based on a bit of research, I think a more correct way to kill child processes would be to send SIGTERM to the children (not the the whole trees, just immediate children) and after some timeout send SIGKILL to the tree. This is what a few init systems will do. It should also be possible to handle signals and ensure that all child processes are cleaned up before exiting.
Related issues
If one task crashes, others keep running #6 included a discussion of what parallel task termination should look like. SIGTERM is the correct signal to start with but it does need to be followed up with.
The text was updated successfully, but these errors were encountered:
Given the following
package.json
file (cruft removed):Racing
a
,b
, andsleep10s
should terminatea
andb
whensleep 10
exits after 10 seconds but insteadrun-p
hangs:This is because
b
doesn't correctly handleSIGTERM
and needs to be sentSIGKILL
.Racing tasks that do correctly respond to
SIGTERM
works fine:What's worse is that further sending
SIGINT
torun-p
will cause it to exit (with130
) and orphanb
. The process tree while hanging:The process tree after
SIGINT
:Example programs
test/programs/a
(correctly responds toSIGTERM
):test/programs/b
(incorrectly ignoresSIGTERM
):Possible solution
Based on a bit of research, I think a more correct way to kill child processes would be to send
SIGTERM
to the children (not the the whole trees, just immediate children) and after some timeout sendSIGKILL
to the tree. This is what a few init systems will do. It should also be possible to handle signals and ensure that all child processes are cleaned up before exiting.Related issues
SIGTERM
is the correct signal to start with but it does need to be followed up with.The text was updated successfully, but these errors were encountered: