From the documentation for Process.kill
:
Sends the given signal to the specified process id(s) if pid is positive. If pid is zero signal is sent to all processes whose group ID is equal to the group ID of the process. signal may be an integer signal number or a POSIX signal name (either with or without a SIG prefix). If signal is negative (or starts with a minus sign), kills process groups instead of processes. Not all signals are available on all platforms.
Okay, that's pretty vague. Which signals are available on what platforms? Are there any signals available on Windows?
(I tried Process.kill(9, pid)
on Windows before and it didn't throw an error. It didn't kill the process either though... But Process.kill("TERM", pid)
did throw an error. Go figure.)
kill ends a process by sending it a signal. The default signal is SIGTERM. kill is a built-in shell command.
The kill command in UNIX enables the user to send a signal to a process. A signal is a message sent to a process to interrupt it and cause a response. If the process has been designed to respond to signals of the type sent it does so; otherwise, it terminates.
taskkill.exe taskkill /? He adds: The /f switch would force the kill, but not using it just sends the termination signal so the application closes gracefully.
The kill -9 command sends a SIGKILL signal indicating to a service to shut down immediately. An unresponsive program will ignore a kill command, but it will shut down whenever a kill -9 command is issued. Use this command with caution.
I think I found a solution. To find out what signals your current platform supports, run this:
ruby -e "puts Signal.list"
On Windows:
{"EXIT"=>0, "INT"=>2, "ILL"=>4, "ABRT"=>22, "FPE"=>8, "KILL"=>9, "SEGV"=>11, "TERM"=>15}
In this article
http://blog.robseaman.com/2008/12/12/sending-ctrl-c-to-a-subprocess-with-ruby
There is good mention of process.kill
and its turn-around mechanism
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With