winsw: Service not sending SIGINT properly to java
I have a “Hello world” class (https://gist.github.com/treaz/19c8fb4a90e1cb4b9448) running as a service powered by winsw 1.17.
Stopping the service (from windows) does not work as expected (graceful shutdown). I see the following in the logs:
2015-04-23 18:47:52 - Started 18060
2015-04-23 18:47:56 - Stopping testService
2015-04-23 18:47:56 - ProcessKill 18060
2015-04-23 18:47:57 - Found child process: 6540 Name: conhost.exe
2015-04-23 18:47:57 - Stopping process 6540
2015-04-23 18:47:57 - Send SIGINT 6540
2015-04-23 18:47:57 - SIGINT to 6540 failed - Killing as fallback
2015-04-23 18:47:57 - Stopping process 18060
2015-04-23 18:47:57 - Send SIGINT 18060
2015-04-23 18:47:57 - SIGINT to 18060 failed - Killing as fallback
2015-04-23 18:47:57 - Finished testService
I was expecting this to work in 1.17 (according to this https://github.com/kohsuke/winsw/issues/41)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- Issue #181 - WinSW.NET2.exe - ILMerge should explicitly define v2 as a TargetPlatformVersion (#188) * Fixes #95 - Service not sending SIGINT properly to java Detach from console process after sen... — committed to winsw/winsw by mpana 7 years ago
- Fixes #95 - Service not sending SIGINT properly to java (#186) * Fixes #95 - Service not sending SIGINT properly to java Detach from console process after sending SIGINT to java. Note: we still n... — committed to winsw/winsw by mpana 7 years ago
- Changelog: Noting #95 and #181 towards 2.0.2 — committed to winsw/winsw by oleg-nenashev 7 years ago
- Update winsw to 2.0.2 This update includes a fix to improve termination of child processes. See https://github.com/kohsuke/winsw/issues/95 and https://github.com/kohsuke/winsw/pull/186 — committed to sensu/sensu-omnibus by cwjohnston 7 years ago
Same issue here. My service wrapper runs a batch file (created by the gradle application plugin). Unfortunately, Windows doesn’t have the equivalent of
exec
in bash, socmd
stays in the process tree of the started service, as well as the actual java process.Using
<stopparentprocessfirst>true</stopparentprocessfirst>
as suggested by @rsargant does seem to work, but not super-cleanly: the wrapper still has lots of errors about missing / already killed processes:I guess this is relying on the java process receiving the SIGINT via propagation from the parent process. Maybe conhost and cmd need special handling? i.e. ignore them, kill other process first (in this case java), then kill conhost and cmd only if necessary.
@oleg-nenashev I have tested the latest build on Windows 10, however I’m seeing the same warnings in the wrapper log and application event log. The workaround suggested
<stopparentprocessfirst>true</stopparentprocessfirst>
makes it so the Java process is stopped first (gracefully), but we’re still failing to SIGINT conhost.exe