Interesting Kill Signal’s in UNIX

Nishanth G
Apr 9 · 3 min read

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 <process_id>

or

kill -15 <process_id>

or

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.

Credit:Turnoff.us

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.

and SIGCONT:

credit:Turnoff.us

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

respond.

How to use them

kill -SIGSTOP <process_id>
kill -SIGCONT <process_id>

Thats all Folks …

IF you have read so far then ….

Nerd For Tech

From Confusion to Clarification

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Nishanth G

Written by

Avg Software Engineer , can’t write any post that takes more than 5 mins

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store