Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Process.kill signals are available on Windows?

Tags:

ruby

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.)

like image 849
Ajedi32 Avatar asked Aug 14 '13 15:08

Ajedi32


People also ask

What signal will kill a process?

kill ends a process by sending it a signal. The default signal is SIGTERM. kill is a built-in shell command.

What is signal in kill 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.

How do I gracefully kill a process in Windows?

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.

What is kill signal 9?

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.


2 Answers

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}
like image 51
Ajedi32 Avatar answered Nov 16 '22 01:11

Ajedi32


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

like image 42
Keval Doshi Avatar answered Nov 16 '22 01:11

Keval Doshi