killx
Send a signal to processes, or list signals.
Mirrors GNU kill. Run it as killx, or as gnux killx.
Synopsis
killx [-s SIGNAL | -SIGNAL] PID...GNU reference
Description
killx sends a signal, TERM by default, to each process PID. The signal is given as -s SIGNAL, -n NUMBER, or -SIGNAL directly (-9, -KILL, -SIGKILL), by name in any case with or without the SIG prefix, or by number; signal 0 sends nothing and only checks that the process exists. A PID that cannot be signaled is reported and the remaining PIDs are still tried. -l prints the signal names, or converts each operand between a name and a number (an exit status above 128 is taken as 128 plus a signal, so 'killx -l 137' prints KILL); -L (or -t) prints a table of numbers, names and descriptions. Unlike GNU kill, killx reads options wherever they appear before '--', so 'killx 1234 -9' sends KILL to 1234 rather than signaling process group 9; a negative PID (a process group, or -1 for every process) must follow '--'. Giving two signals is an error. On Windows, which has no signals, only KILL and TERM can be sent, both by terminating the process, and 0 checks that it exists; any other signal fails with 'Operation not supported'.
gnux's terminal view (BR-13): on a terminal, -l and -L with no operand draw every signal as a framed table of number, name and description, each name colored by what the signal does by default (KILL and STOP, which no program can catch, stand out). Converting an operand (-l 9) is GNU's. --pretty[=WHEN] and --theme=NAME, options of gnux's own matched only in full, choose the view (GNUX_PRETTY, GNUX_THEME); piped or redirected output is always GNU's.
Permissions
A process may be signaled by its owner, or by root (or with CAP_KILL). On Windows, terminating a process needs the right to terminate it, which an administrator has for every process.
Use cases
- Stopping a runaway or hung process.
- Asking a daemon to reload its configuration with HUP.
- Checking whether a process is still alive with signal 0.
- Translating a shell exit status such as 137 into a signal name.
- Stopping a process the same way on Linux, macOS and Windows.
Flags
--help display this help and exit
-l, --list list signal names, or convert signal names to/from numbers
-n, --number NUMBER same as -s, with a NUMBER
--pretty WHEN[="always"] the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
-s, --signal string specify the name or number of the signal to be sent
-L, --table print a table of signal information (also -t)
--theme NAME color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
--version output version information and exitExamples
Ask a process to terminate
killx 1234Kill a process that ignores TERM
killx -9 1234Name the signal
killx -s KILL 1234Ask a daemon to reload its configuration
killx -HUP "$(catx /run/nginx.pid)"Check whether a process is alive
killx -0 1234 && echox aliveSignal several processes
killx -TERM 1234 5678Signal a process group
killx -TERM -- -1234List the signal names
killx -lShow the table of signals
killx -LFind which signal ended a command that exited with 137
killx -l 137Convert a signal name to its number
killx -l TERMSend a signal in the portable gnux shell
gnux shell -c 'killx -0 1234 || echox gone'Options
Each option has a page of its own, with its usage and examples.
- -l, --list: List signal names, or convert signal names to/from numbers.
- -n, --number: Same as
-s, with a NUMBER. - --pretty: The
gnuxterminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default. - -s, --signal: Specify the name or number of the signal to be sent.
- -L, --table: Print a table of signal information (also
-t). - --theme: Color the view with the built-in theme NAME (
gnuxtheme picks and saves one); GNUX_THEME sets the default.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
killx --help # options, first examples, exit status
gnux help killx # this page: the full manual
gnux help killx --OPTION # one option in depth, with its examples