LFCS Exam Preparation: Killing a Process with PID 123 in Linux

How to Kill a Process with PID 123 in Linux

Question

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

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D

The command that kills the process with the PID 123 but allows the process to "clean up" before exiting is the kill command with the -TERM option.

The answer is D. kill -TERM 123.

Here is an explanation of each option:

A. kill -PIPE 123: This option sends the SIGPIPE signal to the process with PID 123. The SIGPIPE signal is used to inform a process that it has attempted to write to a pipe that has been closed.

B. kill -KILL 123: This option sends the SIGKILL signal to the process with PID 123. The SIGKILL signal immediately terminates the process without allowing it to perform any cleanup.

C. kill -STOP 123: This option sends the SIGSTOP signal to the process with PID 123. The SIGSTOP signal suspends the process but does not terminate it.

D. kill -TERM 123: This option sends the SIGTERM signal to the process with PID 123. The SIGTERM signal is a graceful way to terminate a process as it allows the process to perform any cleanup actions it needs before exiting.

Therefore, option D is the correct answer as it kills the process with PID 123 but allows it to clean up before exiting.