While writing a Bourne-compatible startup script you need to make sure that the PID saved in /var/run/legacy.pid still belongs to a running process and that the current user has permission to signal it. The check must not disturb the daemon in any way; you only care about the command's exit status (0 means the process is present and signalable, non-zero means it is not). Which one of the following single-line commands meets this requirement by using the standard kill utility?
Passing signal 0 to the kill command is a POSIX-defined special case. No actual signal is delivered, but the normal existence and permission checks are still performed. Consequently, kill -0 <PID> returns an exit status of 0 if the target process exists and the current user has permission to send it a signal. It returns a non-zero exit status otherwise.
-HUP (signal 1) and -9 (SIGKILL) both transmit real signals that would affect the daemon. The -l option simply lists signal names and does not check a PID. Therefore, using signal 0 is the only option provided that accomplishes the required, non-intrusive check.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the command `kill -0` do specifically?
Open an interactive chat with Bash
Why is `kill -HUP` or `kill -9` not appropriate in this scenario?
Open an interactive chat with Bash
What kind of scenarios would require a non-intrusive check using `kill -0`?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access