How to politely kill windows process from cygwin

1

1

I do have a bat(startJboss.bat) file that starts a JBoss server. When I start it it creates an output to standard cmd (windows) console. When I want to politely end this process I just hit Ctrl + C and the shutdown of the server is as expected.

I want to start the server from cygwin console. So starting is ok, just

cmd /c startJboss.bat

and the server is up. I want to be able to politely stop it from cygwin as well. When hitting the Ctrl + C in cygwin it shuts the wrapping cmd directly but the kill signal is not propagated to the underlying process. So the server is not properly shut down.

How should I propagate the Ctrl + C signal to the process that is started in the bat file?

wertikal

Posted 2013-06-11T07:48:29.387

Reputation: 13

is it an option to use the kill command to send a signal to the process? – golimar – 2013-06-11T09:30:47.547

The kill is sent only to the "cmd" command. I need to propagate it to the startJboss.bat (it starts the server java process) – wertikal – 2013-06-18T08:38:03.370

you can kill any process with the kill or killall commands... – golimar – 2013-06-18T08:44:27.620

pstree should show all the process's children, from that you could write a script to kill them. – Philip Kearns – 2013-06-18T14:28:23.930

Answers

0

Assuming your cygwin console is mintty, it sounds like you're hitting the mintty "Input/Output interaction with alien programs" problem (aka mintty issue #56). In your case this is manifesting as Ctrl-C abruptly killing rather than being passed down to the program as a signal to be caught and handled.

Unfortunately mintty isn't a full Windows console replacement and various behaviours expected by "native" Windows programs are not implemented. However, you might have some joy wrapping such native programs in winpty when running them within mintty...

Anon

Posted 2013-06-11T07:48:29.387

Reputation: 830