DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Understanding Java Signals
  • Angular Input/Output Signals: The New Component Communication
  • Advanced Brain-Computer Interfaces With Java
  • The Technology Powering Trading Signals in Binary Options: A Deep Dive

Trending

  • Comparing SaaS vs. PaaS for Kafka and Flink Data Streaming
  • Subtitles: The Good, the Bad, and the Resource-Heavy
  • How to Format Articles for DZone
  • Develop a Reverse Proxy With Caching in Go

What Are the Process States in Unix/Linux?

In Unix/Linux operating systems, processes can be in one of the five following states. Let’s discuss these states in this article.

By 
Ram Lakshmanan user avatar
Ram Lakshmanan
DZone Core CORE ·
Jan. 28, 21 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
12.3K Views

Join the DZone community and get the full member experience.

Join For Free

In Unix/Linux operating systems, processes can be in one of the following states:

  1. RUNNING and RUNNABLE
  2. INTERRUPTABLE_SLEEP
  3. Uninterruptable_Sleep
  4. Stop
  5. Zombie

Let’s discuss these states in this article.


Fig: Process State Transition Diagram

Fig: Process State Transition Diagram

RUNNING and RUNNABLE

When the CPU executes a process, it will be in a RUNNING state. When the process is not waiting for any resource and ready to be executed by the CPU, it will be in the RUNNABLE state.

Sleeping

The Sleeping state indicates the process is currently waiting on certain resources (like waiting on I/O, waiting on locks, application code making the process to sleep, etc.). There are two types of Sleeping processes:

  • INTERRUPTABLE_SLEEP: When a process is in INTERRUPTABLE_SLEEP, it will wake up from the middle of sleep and process new signals sent to it.
  • UNINTERRUPTABLE_SLEEP: When a process is in UNINTERRUPTABLE_SLEEP, it will not wake up from the middle of sleep even though new signals are sent to it.

How to Kill the Sleeping Process?

If the process is in the INTERRUPTABLE_SLEEP state, then issuing a SIGKILL signal (i.e., ‘kill -9’) to the process, will terminate the process immediately. On the other hand, if the process is in the UNINTERRUPTABLE_SLEEP state, then the issuing a SIGKILL signal will not terminate it immediately. The process will only terminate after it completes its sleep/waiting operation. Thus, if you would like to kill a process that is in the UNINTERRUPTABLE_SLEEP state for a prolonged period then you have to reboot the system; there is no other way.

STOPPED

The STOPPED state indicates that the process has been suspended from proceeding further. In Linux, when you issue the ‘Ctrl + Z’ command it will issue a SIGSTOP signal to the process. When the process receives this signal it will be suspended/stopped from executing further. When a process is in the STOPPED state, it will only handle SIGKILL and SIGCONT signals. SIGKILL signals will terminate the process, but the SIGCONT signal will put the process back into a RUNNING/RUNNABLE state.

ZOMBIE

A process will terminate when it calls a ‘system exit’ API or when someone else kills the process. When a process terminates, it will release all the data structures and the resources it holds. However, it will not release its slot in the ‘process’ table. Instead, the process will send a SIGCHLD signal to its parent process. Now, it’s up to the parent process to release the child process slot in the ‘process’ table. The process will be in a ZOMBIE state from the time the child process issues the SIGCHLD signal until the parent process releases the slot in the ‘process’ table.

How to Kill the ZOMBIE Process?

Issuing ‘kill -9’ on a ZOMBIE process ID will not affect it because the ZOMBIE process doesn’t exist. However, ZOMBIE Process can be killed by sending a SIGCHLD signal to the parent process, using the below kill command:

Shell
 




x


 
1
kill -s SIGCHLD parent-pid


This signal tells the parent process to execute the wait() system call and clean up its ZOMBIE process.

NOTE: Sometimes if the parent process isn’t programmed properly to handle SIGCHLD signals, then the above command will not work. You have to kill the parent process of the ZOMBIE process.

How to Find the Process State

You can find the process state from the following source:

a. The Unix/Linux command-line tool, ‘top,’ will report the process state in the column, ‘s’. Process status is reported with a single character:

  • R — RUNNING/RUNNABLE
  • S — INTERRUPTABLE_SLEEP
  • D — UNINTERRUPTABLE_SLEEP
  • T — STOPPED
  • Z — ZOMBIE
    Fig: Top Tool Reporting
Fig: Top Tool Reporting

b. You can use web-based root cause analysis tools, which will report the process states.

Signal

Opinions expressed by DZone contributors are their own.

Related

  • Understanding Java Signals
  • Angular Input/Output Signals: The New Component Communication
  • Advanced Brain-Computer Interfaces With Java
  • The Technology Powering Trading Signals in Binary Options: A Deep Dive

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!