kill - terminate or signal processes
/usr/bin/kill -s signal_name pid...
/usr/bin/kill -l [exit_status]
/usr/bin/kill [-signal_name] pid...
/usr/bin/kill [-signal_number] pid...
The kill utility sends a signal to the process or processes specified by each pid operand.
For each pid operand, the kill utility performs actions equivalent to the kill(2) function called with the following arguments:
The signaled process must belong to the current user unless the user is the super-user.
See NOTES for descriptions of the shell built-in versions of kill.
The following options are supported:
The following operands are supported:
Process numbers can be found by using ps(1).
The job control job ID notation is not required to work as expected when kill is operating in its own utility execution environment. In either of the following examples:
example% nohup kill %1 & example% system( "kill %1");
kill operates in a different environment and does not share the shell's understanding of job numbers.
When the -l option is not specified, the standard output is not be used.
When the -l option is specified, the symbolic name of each signal is written in the following format:
"%s%c", <signal_name>, <separator>
where the <signal_name> is in upper-case, without the SIG prefix, and the <separator> is either a newline character or a space character. For the last signal written, <separator> is a newline character.
When both the -l option and exit_status operand are specified, the symbolic name of the corresponding signal is written in the following format:
Example 1 Sending the kill signal
Any of the commands:
example% kill -9 100 -165 example% kill -s kill 100 -165 example% kill -s KILL 100 -165
sends the SIGKILL signal to the process whose process ID is 100 and to all processes whose process group ID is 165, assuming the sending process has permission to send that signal to the specified processes, and that they exist.
Example 2 Avoiding ambiguity with an initial negative number
To avoid an ambiguity of an initial negative number argument specifying either a signal number or a process group, the former is always be the case. Therefore, to send the default signal to a process group (for example, 123), an application should use a command similar to one of the following:
example% kill -TERM -123 example% kill -- -123
See environ(5) for descriptions of the following environment variables that affect the execution of kill: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned:
See attributes(5) for descriptions of the following attributes:
csh(1), jobs(1), ksh(1), ksh93(1), ps(1), sh(1), shell_builtins(1), wait(1), kill(2), signal(3C), signal.h(3HEAD), attributes(5), environ(5), standards(5)
The Bourne shell, sh, has a built-in version of kill to provide the functionality of the kill command for processes identified with a jobid. The sh syntax is:
kill [ -sig ] [ pid ] [ %job ]... kill -l
The C-shell, csh, also has a built-in kill command, whose syntax is:
kill [-sig][pid][%job]... kill -l
The csh kill built-in sends the TERM (terminate) signal, by default, or the signal specified, to the specified process ID, the job indicated, or the current job. Signals are either specified by number or by name. There is no default. Typing kill does not send a signal to the current job. If the signal being sent is TERM (terminate) or HUP (hangup), then the job or process is sent a CONT (continue) signal as well.
The syntax of the ksh kill is:
kill [-sig][pid][%job]... kill -l
The ksh kill sends either the TERM (terminate) signal or the specified signal to the specified jobs or processes. Signals are either specified by number or by names (as specified in signal.h(3HEAD) stripped of the SIG prefix). If the signal being sent is TERM (terminate) or HUP (hangup), then the job or process is sent a CONT (continue) signal if it is stopped. The argument job can be the process id of a process that is not a member of one of the active jobs. In the second form, kill -l, the signal numbers and names are listed.
The syntax of the ksh93 kill is:
kill [-n signum] [-s signame] job ... kill [-n signum] [-s signame] -l [arg ...]
With the first form in which -l is not specified, kill sends a signal to one or more processes specified by job. This normally terminates the processes unless the signal is being caught or ignored.
Specify job as one of the following:
If the signal is not specified with either the -n or the -s option, the SIGTERM signal is used.
If -l is specified, and no arg is specified, then kill writes the list of signals to standard output. Otherwise, arg can be either a signal name, or a number representing either a signal number or exit status for a process that was terminated due to a signal. If a name is specified the corresponding signal number is written to standard output. If a number is specified the corresponding signal name is written to standard output.
kill in ksh93 exits with one of the following values:
Закладки на сайте
Проследить за страницей
Created 1996-2021 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру