LFCS · Question #727
Which of the following commands kills the process with the PID 123 but allows the process to "clean up" before exiting?
The correct answer is D. kill -TERM 123. To gracefully terminate a process and allow it to perform cleanup tasks, the kill command should be used with the SIGTERM signal.
Question
Options
- Akill -PIPE 123
- Bkill -KILL 123
- Ckill -STOP 123
- Dkill -TERM 123
How the community answered
(26 responses)- A4% (1)
- B4% (1)
- D92% (24)
Why each option
To gracefully terminate a process and allow it to perform cleanup tasks, the `kill` command should be used with the `SIGTERM` signal.
There is no standard `SIGPIPE` signal intended for process termination; `SIGPIPE` typically occurs when writing to a pipe or socket with no reader.
The `kill -KILL` command sends the `SIGKILL` signal (signal 9), which immediately terminates a process without allowing it to perform any cleanup operations, as it cannot be caught or ignored.
The `kill -STOP` command sends the `SIGSTOP` signal (signal 19), which pauses or suspends a process without terminating it, allowing it to be resumed later with `SIGCONT`.
The `kill -TERM` command sends the `SIGTERM` signal (signal 15) to a process, which is a request for graceful termination. This allows the process to catch the signal, close files, save state, and exit cleanly.
Concept tested: Process signal handling (graceful termination)
Source: https://man7.org/linux/man-pages/man1/kill.1.html
Topics
Community Discussion
No community discussion yet for this question.