SIGTERM, SIGKILL, SIGSTOP and SIGCONT
What is SIGTERM?
SIGTERM means SIGnal and TERMinate ,In UNIX-like systems the SIGTERM signal is used for terminating a program.
The SIGTERM can also be referred as soft kill because the process that receives the SIGTERM signal may choose to ignore it.
In other words, it’s the polite and safe way of killing a process.
By default, kill command sends the SIGTERM signal. You may explicitly mention it with -15 .
How to use SIGTERM command
kill -15 <process_id>
kill -SIGTERM <process_id>
What is SIGKILL?
The SIGKILL is used for immediate termination of a process. This signal cannot be ignored /blocked. The process will be terminated along with its threads.
It is the brutal way of killing a process and it should only be used as the last resort. Suppose you have an unresponsive process that you want to close. The SIGKILL can be used in such a case.
You can use the option -9 to send the SIGKILL signal with the kill command to kill the process immediately
SIGTERM vs SIGKILL:
- SIGTERM gracefully kills the process whereas SIGKILL kills the process immediately.
- SIGTERM signal can be handled, ignored and blocked but SIGKILL cannot be handled or blocked.
- SIGTERM doesn’t kill the child processes. SIGKILL kills the child processes as well.
With SIGTERM, a process gets the time to send the information to its parent and child processes. It’s child processes are handled by init.
Use of SIGKILL may lead to the creation of a zombie process because the killed process doesn’t get the chance to tell its parent process that it has received a kill signal.
What is SIGSTOP ?
Wikipedia has great definitions for SIGSTOP:
When SIGSTOP is sent to a process, the usual behaviour is to pause that process in its current state. The process will only resume execution if it is sent the SIGCONT signal. SIGSTOP and SIGCONT are used for job control in the Unix shell, among other purposes. SIGSTOP cannot be caught or ignored.
When SIGSTOP or SIGTSTP is sent to a process, the usual behaviour is to pause that process in its current state.
The process will only resume execution if it is sent the SIGCONT signal.
SIGSTOP and SIGCONT are used for job control in the Unix shell, among other purposes.
In short, SIGSTOP tells a process to “hold on” and SIGCONT tells a process to “pick up where you left off”. This can work really well for rsync jobs since you can pause the job, clear up some space on the destination device, and then resume the job. The source rsync process just thinks that the destination rsync process is taking a long time to
How to use them
kill -SIGSTOP <process_id>
kill -SIGCONT <process_id>
Thats all Folks …
IF you have read so far then ….