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

A.

kill -PIPE 123
B.
kill -KILL 123
C.
kill -STOP 123
D.
kill -TERM 123

题解

「kill」指令可以尽可能地停止某个进程(process)。kill 可以发送数种不同的信号(signal),如下:
  • SIGHUP(1)
  • SIGINT(2)
  • SIGKILL(9)
  • SIGTERM(15)
  • SIGSTOP(17,19,23)
SIGKILL 和 SIGSTOP 无法被进程给接住,前者会强制结束进程,后者会强制暂停进程。

由于这题要让进程在停止之前去做「clean up」的动作,SIGKILL 和 SIGSTOP 信号无法达成,SIGTERM 才可以,因此答案是选项 D。