Linux Administration
medium

Questão de Linux Administration #019e3987

Enunciado da Questão
Linux Administration
#kill
#sigterm
#signal-handling
#process-termination
Médio

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

Correta

Explicação Oficial / Explicações da Comunidade

The kill command sends a signal to a process. The default signal is SIGTERM (15), which requests the process to terminate gracefully, allowing it to clean up resources, close files, and perform shutdown routines. The command kill -TERM 123 sends SIGTERM to PID 123, enabling a clean exit.

How it Works:

  • SIGTERM (signal 15) is the standard way to politely ask a process to terminate. The process can catch this signal and execute cleanup handlers before exiting.
  • SIGKILL (signal 9) immediately terminates the process without any cleanup, which can lead to data loss or corruption.
  • SIGPIPE (signal 13) is typically sent when a process writes to a pipe with no reader; it is not intended for graceful termination.
  • SIGSTOP (signal 19) pauses the process; it cannot be caught or ignored, and the process remains in memory but does not execute.