Use JobObject to optionally terminate spawned process tree #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the service is requested to stop from the management console or via
sc stop
command, current implementation ofsrvany-ng
does not terminate any descendant processes spawned by the service application.This is in line with the original
srvany
, as documented in the below article:Q&A: Why doesn’t Srvany Close my Application when I Stop the Service? | | The Core Technologies Blog
Still, I thought it would be great if support for process tree termination could be added.
Using Job Objects seems to be most straightforward, so I am sending this PR as a suggestion.
The default behavior is unchanged. Please add and set
UseJobObject
DWORD registry parameter to 1 to enable the new behavior.Note: As written in MS' reference, Job Objects has limitation before Win 8 and Windows Server 2012.
So using Job Object in
srvany-ng
may clash with program already using Job Objects, when running in older environment; hence the optional implementation.Some things that may need to be addressed / discussed:
UseJobObject
may not really convey what it performs and may not be appropriate for registry key