The command kill -TERM 123 kills the process with the PID 123 but allows the process to “clean up” before exiting. The option -TERM specifies the signal to be sent to the process, which is the termination signal (SIGTERM). This signal requests the process to terminate gracefully, which means that the process can perform any necessary actions before exiting, such as closing files, releasing resources, or saving data. The process can also catch the signal and ignore it or handle it in a different way, if it is programmed to do so. The syntax is: kill -TERM pid. For example, kill -TERM 123 will send the SIGTERM signal to the process with the PID 123, asking it to terminate nicely. The other options are not correct because:
A. kill -PIPE 123: This command sends the broken pipe signal (SIGPIPE) to the process, which is not used to kill the process, but to notify it that the other end of a pipe has been closed. This signal is usually ignored by the process, unless it is writing to the pipe, in which case it will cause the process to terminate1.
B. kill -KILL 123: This command sends the kill signal (SIGKILL) to the process, which is the most powerful way to kill the process, but it does not allow the process to “clean up” before exiting. The SIGKILL signal cannot be caught, blocked, or ignored by the process, and it forces the process to terminate immediately, without performing any actions. This command should be used as a last resort, when the process is unresponsive or causing harm to the system2.
C. kill -STOP 123: This command sends the stop signal (SIGSTOP) to the process, which is not used to kill the process, but to pause it. The SIGSTOP signal cannot be caught, blocked, or ignored by the process, and it suspends the execution of the process until it receives a continue signal (SIGCONT). This command can be used to temporarily stop a process from running, without terminating it3. References:
What is the purpose of the SIGPIPE signal? - Stack Overflow
How to kill a process in Linux - LinuxConfig.org
Linux Signals - GeeksforGeeks