#78 Signal Termination to a Process
Signaling process killing is common, but signals are not restricted to it.
List all signals.
$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL ...
List process ids; They are in column PID.
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 23392 14100 ? Ss 09:34 0:04 /usr/lib/systemd/s
Send signal 9, an ignorable signal for termination, to pid 1201.
$ kill -9 1201.
Send signal 15, a non-ignorable signal, to pid 1201.
$ kill -15 1201.
If signal 15, SIGKILL, did not work, a good practice is to check the process state. It is in column STAT of ps aux.
If STAT is prefixed by D like STAT = D+, the process is in uninterruptible sleep. It is usually waiting for I/O like disk filesystem. SIGKILL is queued but won’t take effect until the process is resolved. It may happen with stuck mounts and faulty storage drivers. Try to resolve these by, for example, umount -f /mnt/nfs.
If STAT = Z, it’s a zombie whereby it is already dead but waiting for its parent.
You may get the parent process id (PPID) of pid 1201 by ps -o ppid= -p 1201 to kill or restart it.
$ ps aux | grep 1201
touny 1201 0.0 0.1 25004 20236 ? Ss 09:35 0:01 python /home/touny/Projects/tech-hacks/i3-last-focus-window-closed.py
touny 52606 0.0 0.0 6620 4164 pts/1 S+ 18:56 0:00 grep --color=auto 1201
$ ps -o ppid= -p 1201
1171
$ ps aux | grep 1171
touny 1171 0.0 0.3 132808 47244 ? Ssl 09:35 0:14 i3
touny 1207 0.0 0.1 102192 17260 ? Ssl 09:35 0:13 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.1171
touny 52613 0.0 0.0 6620 4160 pts/1 S+ 18:56 0:00 grep --color=auto 1171
Cites: