Difficulty: Medium
Correct Answer: kill 0
Explanation:
Introduction / Context:
UNIX process management hinges on signals delivered by the kill utility. Besides sending a signal to a single PID, kill can target groups of processes. Understanding special PID values helps you control runaway processes without logging out or killing the login shell itself.
Given Data / Assumptions:
Concept / Approach:
By POSIX convention, kill 0 sends a signal to every process in the same process group as the sender. In many interactive shells, the login shell is the group leader and does not terminate when you send SIGTERM to the group from within it (though behavior can vary by shell and signal). This makes kill 0 a practical way to clean up child jobs you launched. You can also specify signals, for example kill -TERM 0 or kill -KILL 0 for a forceful stop.
Step-by-Step Solution:
Verification / Alternative check:
Compare before/after output of ps -o pid,pgid,comm to observe signals delivered to the shared process group. Confirm your shell remains functional.
Why Other Options Are Wrong:
a: kill 1 targets PID 1 (init/systemd)—never use for this purpose.
c, d: cancel is not a standard UNIX signal command.
e: Not applicable since kill 0 is the correct group-targeting usage.
Common Pitfalls:
Assuming identical behavior across all shells; using -KILL immediately (gives no cleanup chance); running the command under sudo, which may broaden impact beyond your own processes.
Final Answer:
kill 0
Discussion & Comments