Understanding Process Status Codes in Linux: Decoding S+, Sl+, T, R+ in `ps ax | grep node` Output


2 views

When you run ps ax | grep node in Linux, the output shows several columns including the process status (STAT column). Here's what each status code means:

S+  - Interruptible sleep (waiting for an event to complete), foreground process
Sl+ - Interruptible sleep, multi-threaded process, foreground process
T   - Stopped by job control signal
R+  - Running or runnable (on run queue), foreground process

Let's examine your output:

23308 pts/3    S+     0:00 sudo node index.js
23310 pts/3    Sl+    0:00 node index.js
23568 pts/1    T      0:00 sudo node index.js
23824 pts/4    S+     0:00 sudo node index.js
23826 pts/4    Sl+    0:00 node index.js
24202 pts/5    R+     0:00 grep --color=auto node

Based on the status codes:

  • S+/Sl+ processes: These are your running Node.js applications (23308, 23310, 23824, 23826)
  • T process: This is a stopped Node.js process (23568) that might need investigation
  • R+ process: This is your grep command itself (24202) which will disappear after execution

To safely terminate Node.js processes:

# Kill by PID (example for process 23308)
kill -9 23308

# Kill all Node.js processes (be careful with this!)
pkill -9 node

# For stopped processes (status T), you might want to first try:
kill -CONT 23568  # Send continue signal
kill -9 23568     # Then force kill if needed

Notice that some processes are sudo node while others are just node. This indicates:

  • The sudo processes are the parent processes
  • The plain node processes are the child processes

For complete cleanup, you should kill both the parent and child processes.

A better way to view and manage processes is using pstree:

pstree -p | grep node

This will show you the process hierarchy, making it easier to identify which processes to kill.

After killing processes, check for any zombie processes (status Z):

ps aux | grep 'Z'

If you find any, you may need to kill their parent processes to properly clean them up.

For production environments, consider using process managers like PM2:

npm install pm2 -g
pm2 start index.js
pm2 list       # View running processes
pm2 stop all   # Stop all processes cleanly

When examining process listings in Linux, the status column reveals crucial information about each process's execution state. Here's what each symbol means in your ps ax | grep node output:

S+ - Interruptible sleep (waiting for event) with foreground process group
Sl+ - Interruptible sleep with multi-threaded process (using threads) in foreground
T - Stopped by job control signal
R+ - Running or runnable in foreground process group

Let's break down your output line by line:

1. 23308 pts/3 S+: A sudo process waiting to execute node (interruptible sleep)
2. 23310 pts/3 Sl+: Actual Node.js process running with threads
3. 23568 pts/1 T: Stopped sudo process (likely with Ctrl+Z)
4. 23824 pts/4 S+: Another waiting sudo process
5. 23826 pts/4 Sl+: Active Node.js application
6. 24202 pts/5 R+: Your grep command itself

For clean shutdown of Node.js instances, target processes with these patterns:


# Kill the actual Node processes (Sl+ status)
kill -9 23310 23826

# Then clean up the associated sudo processes
kill -9 23308 23824

# For stopped processes (T status)
kill -9 23568

Instead of manually parsing ps output, consider these alternatives:


# Find all Node processes including child processes
pgrep -a node

# Alternative using pstree for visualization
pstree -p | grep node

# Force kill all Node processes (be careful!)
pkill -9 node

When dealing with Node.js cluster processes, you'll see multiple Sl+ entries:


const cluster = require('cluster');
const numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
console.log(Master ${process.pid} is running);

// Fork workers
for (let i = 0; i < numCPUs; i++) { cluster.fork(); } } else { // Workers can share any TCP connection console.log(Worker ${process.pid} started); }

This would show multiple Sl+ processes in ps output - one for each worker. Kill the master process first (lowest PID) and workers will terminate gracefully.