Linux and Command-Line Basics

When stopping a process that has stopped responding, it is recommended to first use "kill <process ID>" and to use "kill -9 <process ID>" only if that does not end it. Which of the following is the reason?

  1. AThe default SIGTERM (number 15) can be received by the process so that it can clean up before exiting, whereas SIGKILL (number 9) cannot be received and ends it forcibly without cleanup
  2. BSIGTERM (number 15), which kill sends by default, ends everything including child processes, whereas SIGKILL (number 9) ends only the specified process and so has less impact
  3. CSIGKILL (number 9) can be received by the process so that it can clean up before exiting, whereas SIGTERM (number 15), which kill sends by default, cannot be ignored and ends it at once
Show answer and explanation

Answer: A. The default SIGTERM (number 15) can be received by the process so that it can clean up before exiting, whereas SIGKILL (number 9) cannot be received and ends it forcibly without cleanup

A signal is a short notification by which the OS tells a process about an event, and each has a fixed number and name. Without options, kill sends SIGTERM (number 15); a program can provide a routine (handler) that receives it, saving files in progress or deleting temporary files before exiting. SIGKILL (number 9) can be neither received nor ignored by the process, and the kernel ends it forcibly, so half-written files may be left corrupted. The ID of the process to stop is found with ps or top.

  • A. Correct. SIGTERM gives a chance to clean up, while SIGKILL ends the process forcibly.
  • B. Both signals are sent to the specified process. Whether child processes also end is not decided by the type of signal.
  • C. The behavior of SIGTERM and SIGKILL is reversed. The one that can be received for cleanup is SIGTERM.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. While a long-running ./sim.sh is running in a terminal, you want to use other commands in the same terminal. Which of the following is what happens when you press Ctrl+Z and then run bg?
  2. On a server reached over SSH, a long-running task was started with "./run.sh &", and when the connection was closed the task stopped too. Which of the following is the most appropriate way to start it so that it keeps running after the connection is closed?
  3. When the two lines above are run in a shell, which of the following are the characters shown?
  4. When the commands above are run in order, which of the following is the output of the two echo commands?
  5. As shown above, the script s.sh is run with arguments. Which of the following is the output?