Skip to main content

Command Palette

Search for a command to run...

Process States and Kill command

Published
2 min read
Process States and Kill command
M

Hi, How are you !! Hope you doing good....

I got introduced to Cloud initially. As I went ahead learning what is cloud and how it works, then got to know a field which is DevOps that makes Cloud model more effective.

So, as I started working & got good experience on AWS. I have been learning the DevOps tool and technologies on how to use it with the Cloud, which will give me good understanding on how Cloud and DevOps go hand in hand to deploy my applications.

Last Blog Review

In the last blog we understood, what is process management, parent process, forking, example of it and command for knowing the process id.

Process States →

  1. Running - In this state the process is in running state or ready to run

  2. Waiting - A process is waiting for a resource

  3. Stopped - A process is stopped for example after receiving signal

  4. Zombie - A process is exited successfully, but its state change is not yet acknowledge by the parent.

What is process termination →

In general scenarios, when a process terminates it free’s up allocated resources. If a shell has forked a subprocess, then it wait for them to finish it’s task first (other than background process).

In other cases the process may not behave normally and can be in waiting state or consuming resources for a longer time.

In some other cases, if process is not required we can kill the process and free up resources.

KILL command →

The kill command sends a specific signal to the specified process, if no signal is provided the default sigterm signal is sent.

Syntax

kill PID or kill -signal PID

How to kill a process →

  1. To kill a process we will get the PID first

     $$ pidof google      #GEtting PID of google
     1002
    
     $$ kill 1002         #Google will be terminated
    
     $$ touch new.txr     #starting a new process
     $$ pidof touch         
     1434
    
     $$ kill -SIGSTOP 1434 #Sending signal to stop touch process
     [1]+ Stopped
    
  2. Here we used SIGSTOP signal to stop the touch process instead of directly killing it. If we want to kill the process we can use SIGKILL signal

     kill -SIGKILL 1434
    

Conclusion →

In this blog we understood, multiple process states, what it means to terminate a process. KILL command and how to use a KILL command to terminate a process.

💡
That’s a wrap for today’s post! I hope this has given you some valuable insights. Be sure to explore more articles on our blog for further tips and advice. See you in the next post!

More from this blog

Mihir's Tech blog

69 posts