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

Most upvoted comments

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, so cmd 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:

2016-11-11 14:46:54 - Stopping myapp
2016-11-11 14:46:54 - ProcessKill 21024
2016-11-11 14:46:54 - Found child process: 1144 Name: conhost.exe
2016-11-11 14:46:54 - Found child process: 41304 Name: java.exe
2016-11-11 14:46:54 - Stopping process 21024
2016-11-11 14:46:54 - Send SIGINT 21024
2016-11-11 14:46:55 - SIGINT to21024 successful
2016-11-11 14:46:55 - Stopping process 1144
2016-11-11 14:46:55 - Send SIGINT 1144
2016-11-11 14:46:55 - SIGINT to 1144 failed - Killing as fallback
2016-11-11 14:46:55 - Stopping process 41304
2016-11-11 14:46:55 - Process 41304 is already stopped
2016-11-11 14:46:55 - Finished myapp

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