# Kill myself after 30 seconds if still running
(sleep 30 && kill $$) & long-running-command
# Kill myself after 30 seconds if still running
(sleep 30 && kill $$) & long-running-command
# Kill myself after 30 seconds if still running
(sleep 30 && kill $$) & long-running-command
timeout 30 long-running-command
timeout 30 long-running-command
timeout 30 long-running-command
kill -HUP $(cat /var/run/nginx.pid) # reload nginx config
# or, in modern times:
-weight: 500;">systemctl reload nginx # which does the same thing
kill -HUP $(cat /var/run/nginx.pid) # reload nginx config
# or, in modern times:
-weight: 500;">systemctl reload nginx # which does the same thing
kill -HUP $(cat /var/run/nginx.pid) # reload nginx config
# or, in modern times:
-weight: 500;">systemctl reload nginx # which does the same thing - Default action. The kernel handles it. Most signals kill the process; some -weight: 500;">stop it; one does nothing by default. The process doesn't have a say.
- Catch it. The process has installed a signal handler — a function. The kernel calls that function instead. When the handler returns, the process resumes whatever it was doing.
- Ignore it. The process has said "I don't care about this signal." The kernel checks, shrugs, and moves on. - A signal is a small out-of-band notification delivered by the kernel to a process.
- Disposition is per-process, per-signal: default action, catch with a handler, or ignore.
- SIGKILL (9) and SIGSTOP (19) cannot be caught or ignored — the kernel handles them unconditionally.
- kill -9 can fail to immediately kill a process in uninterruptible sleep (D state).
- The terminal driver sends SIGINT on Ctrl-C and SIGTSTP on Ctrl-Z to the entire foreground process group.
- SIGPIPE fires when you write to a pipe with no readers — that's the BrokenPipeError you've seen.
- SIGWINCH fires whenever the terminal is resized — programs catch it to redraw their UI.
- SIGCHLD notifies a parent when a child changes state; catching it is how you avoid zombie processes.
- SIGHUP means "terminal disconnected" to interactive programs, and "reload config" to daemons. Both are real.
- Process groups, nohup, session architecture, and setsid() are covered in the next post: Sessions and Process Groups. - man 7 signal — the complete Linux signal reference. Every signal, its default action, whether it can be caught.
- man 2 sigaction — the correct way to -weight: 500;">install a signal handler (not the older signal(2), which has subtle portability problems).
- man 2 kill, man 2 waitpid — the syscalls for sending signals and reaping children.
- Advanced Programming in the UNIX Environment — Stevens and Rago, Chapter 10 on signals. Still the best treatment of the full signal model in print.