Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

kill

Send a signal to a process by PID.

Description

Sends a signal to one or more processes (or process groups) identified by PID. Without a signal flag, sends SIGTERM. Also exposes the canonical signal table via -l and -L, so it can be used to convert between signal names and numbers without sending anything.

Inputs

  • kill(2) syscall via libc::kill for delivery.
  • No /proc access; PIDs are passed straight through to the kernel.

Synopses

kill [options] <pid> [<pid> ...]
kill -l [<signal> ...]
kill -L

Arguments

FlagDescription
-s, --signal SIGSignal to send – name or number. Default: TERM
-<SIG> (e.g. -9, -KILL, -SIGKILL)Same as -s SIG. Equivalent forms; the leading - plus signal spec is consumed if -s was not given
-l, --list [SIG ...]List signal names. With no arguments, prints all signal names separated by spaces. With arguments, converts each from name to number or number to name (one per line)
-L, --tablePrint the signal table – number and name pairs, eight per line
--helpPrint help
-V, --versionPrint version
--End of options; subsequent arguments are PIDs even if they start with -
<pid>One or more PIDs to signal (see semantics below)

PID semantics

Following kill(2):

PIDEffect
> 0Signal the process with that PID
0Signal every process in the caller’s process group
-1Signal every process the caller is permitted to signal, except init
< -1Signal every process in the process group with PID |pid|

A negative PID that follows -- is parsed as a PID. Without --, a leading negative argument is consumed as the signal spec when -s was not given.

Behavior

Signal selection precedence

  1. -s SIG / --signal SIG
  2. A leading -N or -NAME argument (e.g. kill -9 1234, kill -KILL 1234)
  3. Default: TERM

Signal 0 is the null signal – delivery is checked but no signal is sent. kill -0 PID is the standard way to test whether a process exists and is signalable by the caller.

-l / --list

InvocationOutput
kill -lAll signal names (no SIG prefix), space-separated, one line
kill -l NName for signal number N
kill -l NAMENumber for signal name (with or without SIG prefix)
kill -l N1 N2 ...Each conversion on its own line

-L / --table

Prints the signal table eight pairs per line, formatted as:

 1 HUP   2 INT   3 QUIT   4 ILL   5 TRAP   6 ABRT   7 BUS   8 FPE
 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM 15 TERM 16 STKFLT
...

Supported signals

Standard signals 1–31 (HUP, INT, QUIT, ILL, TRAP, ABRT/IOT, BUS, FPE, KILL, USR1, SEGV, USR2, PIPE, ALRM, TERM, STKFLT, CHLD/CLD, CONT, STOP, TSTP, TTIN, TTOU, URG, XCPU, XFSZ, VTALRM, PROF, WINCH, IO/POLL, PWR, SYS). Real-time signals (SIGRTMIN..SIGRTMAX) are not yet listed by -l or -L but can still be sent by number.

Exit codes

CodeMeaning
0All signals delivered successfully (or a successful list/table operation)
1At least one signal delivery failed (no such process, permission denied, etc.)
2Usage error (unknown signal, no PIDs given, invalid PID)