kill — End a process or job, or send it a signal

Format

  • kill –l [exit_status]
  • kill [–s signal_name] [
  • kill –K [pid...][job-identifier...]
  • kill [signal_name] [pid …] [job-identifier …]
  • kill [signal_number] [pid …] [job-identifier …]

tcsh shell:

Description

kill ends a process by sending it a signal. The default signal is SIGTERM.

kill is a built-in shell command.

In the tcsh shell, kill [-signal] %job|pid … sends the specified signal (or if none is given, the TERM (terminate) signal) to the specified jobs or processes. job can be a number, a string, '', %, + or - . Signals are either given by number or by name. Enter the signal_name with uppercase characters. For example, if you want to send the SIGTERM signal, you would enter kill -TERM pid not kill -SIGTERM pid.

Restriction: When using the tcsh kill command, do not use the first three characters (SIG) of the signal_name.

There is no default job. Specifying kill alone does not send a signal to the current job. If the signal being sent is TERM or HUP (hangup), then the job or process is sent a CONT (continue) signal as well.

kill -l lists the signal names. See tcsh — Invoke a C shell.

The signal_numbers and signal_names described in Options are also used with the tcsh kill command.

Options

–K
Sends a superkill signal to force the ending of a process or job that did not end as a result of a prior KILL signal. The process is ended with a non-retryable abend. The regular KILL signal must have been sent at least 3 seconds before the superkill signal is sent. The superkill signal cannot be sent to a process group (by using pid of 0 or a negative number) or to all processes (by using a pid of -1).
–l
Displays the names of all supported signals. If you specify exit_status and it is the exit code of an ended process, kill displays the ending signal of that process.
–s signal_name
Sends the signal signal_name to the process instead of the SIGTERM signal. When using the kill command, do not use the first three characters (SIG) of the signal_name. Enter the signal_name with uppercase characters. For example, if you want to send the SIGABRT signal, enter:
kill –s ABRT pid
signal_name
(Obsolete.) Same as –s signal_name.
signal_number
(Obsolete.) A non-negative integer representing the signal to be sent to the process, instead of SIGTERM.

The signal_number represents the following signal names:

0
 SIGNULL
1
 SIGHUP
2
 SIGINT
3
 SIGQUIT
4
 SIGILL
5
 SIGPOLL
6
 SIGABRT
7
 SIGSTOP
8
 SIGFPE
9
 SIGKILL
10
 SIGBUS
11
 SIGSEGV
12
 SIGSYS
13
 SIGPIPE
14
 SIGALRM
15
 SIGTERM
16
 SIGUSR1
17
 SIGUSR2
18
 SIGABND
19
 SIGCONT
20
 SIGCHLD
21
 SIGTTIN
22
 SIGTTOU
23
 SIGIO
24
 SIGQUIT
25
 SIGTSTP
26
 SIGTRAP
27
 SIGIOERR
28
 SIGWINCH
29
 SIGXCPU
30
 SIGXFSZ
31
 SIGVTALRM
32
 SIGPROF
37
 SIGTRACE
38
 SIGDCE
39
 SIGDUMP

The signal_numbers (3 and 6) associated with SIGQUIT and SIGABRT, respectively, differ from the values of SIGQUIT and SIGABRT used by the z/OS kernel, but they are supported for compatibility with other UNIX platforms. (The kill command will send the SIGQUIT or SIGABRT to the process.) This note is also true for kill in the tcsh shell.

Operands

job-identifier
Specifies the job identifier reported by the shell when a process is started with &. It is one way to identify a process. It is also reported by the jobs command. When using the job identifier with the kill command, the job identifier must be prefaced with a percent (%) sign. For example, if the job identifier is 2, the kill command would be entered as follows:
kill –s KILL %2
pid
Specifies the process ID that the shell reports when a process is started with &. You can also find it using the ps command. The pid argument is a number that may be specified as octal, decimal, or hexadecimal. Process IDs are reported in decimal. kill supports negative values for pid.
If pid is negative but not -1, the signal is sent to all processes whose process group ID is equal to the absolute value of pid. The negative pid is specified in this way:
kill –KILL –– –nn
where nn is the process group ID and may have a range of 2 to 7 digits (nn to nnnnnnn).
kill –s KILL –– –9812753
The format must include the –– before the –nn in order to specify the process group ID.

If pid is 0, the signal is sent to all processes in the process group of the invoker.

The process to be killed must belong to the current user; however, any process can be killed by a superuser.

Localization

kill uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Usage notes

  1. z/OS® UNIX signal delivery restrictions are documented in the "Environmental Restrictions" section of z/OS UNIX System Services Programming: Assembler Callable Services Reference.

Exit values

0
Successful completion
1
Failure due to one of the following:
  • The job or process did not exist
  • There was an error in command-line syntax
2
Failure due to one of the following:
  • Two jobs or processes did not exist
  • Incorrect command-line argument
  • Incorrect signal
>2
Tells the number of processes that could not be killed

Messages

Possible error messages include:
job-identifier is not a job
You specified an incorrect ID.
signal_name is not a valid signal
You specified a noninteger signal for kill, or you specified a signal that is outside the range of valid signal numbers.

Portability

POSIX.2, X/Open Portability Guide.

Related information

jobs, ps, sh, tcsh