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
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Zone-Free Angular: Unlocking High-Performance Change Detection With Signals and Modern Reactivity
  • Designing Self-Healing AI Infrastructure: The Role of Autonomous Recovery
  • Architecting AI-Native Cloud Platforms: Signals to Insights to Actions
  • Runtime FinOps: Making Cloud Cost Observable

Trending

  • The AI Autonomy Spectrum: 7 Architecture Patterns for Intelligent Applications
  • Observability for Agents and Workflows: Tracing Prompts, Tool Calls, and Business Outcomes End-to-End
  • If You Can Survive a Toddler, You Can Ship LLMs in Production
  • Implementing the Planning Pattern With Java Enterprise and LangChain4j

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.8K 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

  • Zone-Free Angular: Unlocking High-Performance Change Detection With Signals and Modern Reactivity
  • Designing Self-Healing AI Infrastructure: The Role of Autonomous Recovery
  • Architecting AI-Native Cloud Platforms: Signals to Insights to Actions
  • Runtime FinOps: Making Cloud Cost Observable

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook