Red Hat Certified System Administrator RHCSA · Free Practice Question Easy

Question 16

Which of the following commands kills the process with the PID 112 but allows the process to "clean up" before exiting?

  • A

    kill -KILL 112

  • B

    kill -PIPE 112

  • C

    kill -STOP 112

  • D

    kill -TERM 112

Reveal correct answer

Correct answer: D

Explanation

The correct command is:

Explanation:

The command kill -TERM 112 sends a termination signal (SIGTERM) to the process with the Process ID (PID) 112. This signal requests the process to terminate gracefully, allowing it to carry out any necessary cleanup operations, such as saving data or closing open resources, before it exits.

  1. Signal Type (-TERM):

    • SIGTERM (signal number 15) is a soft termination signal that tells a process to end but gives it the chance to do so cleanly. Processes that handle SIGTERM can perform final actions like saving state or closing files before actually terminating.

  2. Alternative Signal - -KILL:

    • If the process does not respond to SIGTERM, you can use the stronger kill -KILL 112 (or kill -9 112). This sends a SIGKILL (signal number 9), which forcefully stops the process without allowing any cleanup. SIGKILL is only used when a process becomes unresponsive to SIGTERM.

  3. Why SIGTERM First?:

    • Using kill -TERM is a best practice as it gives the process a chance to end in a controlled manner, reducing the risk of data corruption or partial writes. Using kill -KILL or other more forceful signals should only be a last resort if the process ignores SIGTERM or becomes unresponsive.

  4. Other Options (-PIPE and -STOP):

    • kill -PIPE: There is no -PIPE option for the kill command; this would be an invalid option.

    • kill -STOP: This command pauses the process but does not terminate it, so it does not fulfill the requirement of ending the process. SIGSTOP is useful for temporarily suspending a process to resume later with SIGCONT.

Summary:

For a controlled termination that allows the process to clean up, kill -TERM is the appropriate command. Using a hard kill, such as kill -KILL, bypasses cleanup and should only be used if termination with kill -TERM fails.

Example Usage:

This command prompts the process to shut down in an orderly fashion, reducing the chance of data loss or incomplete tasks.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need