Movatterモバイル変換


[0]ホーム

URL:


functions /kill
(source,CPAN)
You are viewing the version of this documentation from Perl 5.26.0.View the latest version
#kill SIGNAL, LIST
#kill SIGNAL

Sends a signal to a list of processes. Returns the number of arguments that were successfully used to signal (which is not necessarily the same as the number of processes actually killed, e.g. where a process group is killed).

my $cnt = kill 'HUP', $child1, $child2;kill 'KILL', @goners;

SIGNAL may be either a signal name (a string) or a signal number. A signal name may start with aSIG prefix, thusFOO andSIGFOO refer to the same signal. The string form of SIGNAL is recommended for portability because the same signal may have different numbers in different operating systems.

A list of signal names supported by the current platform can be found in$Config{sig_name}, which is provided by theConfig module. SeeConfig for more details.

A negative signal name is the same as a negative signal number, killing process groups instead of processes. For example,kill '-KILL', $pgrp andkill -9, $pgrp will sendSIGKILL to the entire process group specified. That means you usually want to use positive not negative signals.

If SIGNAL is either the number 0 or the stringZERO (orSIGZERO), no signal is sent to the process, butkill checks whether it'spossible to send a signal to it (that means, to be brief, that the process is owned by the same user, or we are the super-user). This is useful to check that a child process is still alive (even if only as a zombie) and hasn't changed its UID. Seeperlport for notes on the portability of this construct.

The behavior of kill when aPROCESS number is zero or negative depends on the operating system. For example, on POSIX-conforming systems, zero will signal the current process group, -1 will signal all processes, and any other negative PROCESS number will act as a negative signal number and kill the entire process group specified.

If both the SIGNAL and the PROCESS are negative, the results are undefined. A warning may be produced in a future version.

See"Signals" in perlipc for more details.

On some platforms such as Windows where thefork(2) system call is not available, Perl can be built to emulatefork at the interpreter level. This emulation has limitations related to kill that have to be considered, for code running on Windows and in code intended to be portable.

Seeperlfork for more details.

If there is noLIST of processes, no signal is sent, and the return value is 0. This form is sometimes used, however, because it causes tainting checks to be run. But see"Laundering and Detecting Tainted Data" in perlsec.

Portability issues:"kill" in perlport.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2025 Movatter.jp