Jump to content

Perl Programming/Keywords/kill

From Wikibooks, open books for an open world
Previous: keys Keywords Next: last

The kill keyword

[edit | edit source]

The kill command sends a signal to a LIST of processes. Returns the number of arguments that were successfully used to signal. This is not necessarily the same as the number of processes actually killed, as a process group can also be killed. SIGNAL is either a name of a signal, or a signal number.

If the signal name is negative, it is the same as a negative number and kills a group of processes.

If SIGNAL is either 0, the string SIGZERO, or ZERO, no signal is sent to the process, but the command checks whether it's possible to send a signal to it. This is useful to check that a child process is still alive with the same UID.

Syntax

[edit | edit source]
 kill SIGNAL, LIST  kill SIGNAL 

Examples

[edit | edit source]
 $cnt = kill 'HUP', $child1, $child2;  kill 'KILL', @goners;  kill '-KILL', $processes; # same as next line  kill -9, $processes; # same as previous line 
Previous: keys Keywords Next: last