-
Notifications
You must be signed in to change notification settings - Fork 653
Conversation
On Windows, the default behavior for child processes is not to be killed when their parent die. This is different from the behavior of most platforms. This change uses [Windows Job Objects](http://msdn.microsoft.com/en-us/library/windows/desktop/ms684161(v=vs.85).aspx) to implement the same behavior for Windows. A test named `spawn_tree` was added to verify this behavior: the test spawns a child and a grandchild. The child exits after 200ms and the grandchild asserts after 5 seconds. If the process tree is constructed propertly, the child should kill the grandchild and then the assertion is not hit. Credits: @saary, @yosefd, [iisnode](https://github.com/tjanczuk/iisnode)
Tested on MaxOSX
After testing this on a MacOSX and on Ubuntu, it seems like the default behavior is actually to keep the grandchild alive. The only difference in behavior as oppose to Windows is that Windows keeps the root process hanging as long as the grandchild is not killed while on the *nix systems, the grandchild is completely detached.
Any suggestions on how to proceed with this? |
I think that behavior on other systems is not good and hence we can propose change in behavior. Can it be controlled from node when running on UNIX or is it something inherent to UNIX? Sent from my Windows Phone From: Elad Ben-Israel I tested this on a MacOSX and on Ubuntu and it seems like the default behavior is actually to keep the grandchild alive. The only difference in behavior as oppose to Windows is that Windows keeps the root process hanging as long as the grandchild is not killed while on the *nix systems, the grandchild is completely detached.
Any suggestions on how to proceed with this? Reply to this email directly or view it on GitHub: |
* | ||
* *nix systems behave like this by default, but in Windows, the following is required: | ||
* | ||
* 1) When the process is initialized, a new job object is created with the attribute KILL_ON_JOB_CLOSE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure that you don't go over 80 characters per line
@AvianFlu, I like the concept of How about we merge #338 and #329 into a single feature such that Also, did you run into the Windows bug where if a grandchild is still alive, the child's streams are not closed and then the |
OK, closing for now after further investigation as this discusses two different issues:
|
#343 fixes the bug on Windows |
On Windows, the default behavior for child processes is not to be killed when their parent die.
This change uses Windows Job Objects to implement the stick process trees for Windows.
A test named
spawn_tree
was added to verify this behavior: the test spawns a child and a grandchild. The child exits after 200ms and the grandchild asserts after 5 seconds. If the process tree is constructed propertly, thechild should kill the grandchild and then the assertion is not hit.
Credits: @saary, @yosefd, iisnode