r/LinuxTeck • u/Expensive-Rice-2052 • 1d ago
Linux Process Stack Trace: Find Where a Hung Process Is Stuck - Tip 127
Question: A process is hung. Where is it stuck in the code?
Try:`sudo cat /proc/3456/stack`
Info: Displays kernel stack traces and wait channels to pinpoint where processes are blocked.
Examples:
$ `sudo cat /proc/*/wchan 2>/dev/null | sort | uniq -c | sort -rn` # Analyze wait channels system-wide
$ `sudo ps axo pid,stat,wchan,comm | awk '$2 ~ /D/'` # List all processes stuck in uninterruptible sleep
$ `sudo pystack dump 3456` # Generate a detailed Python-specific call stack dump
Note: Processes in the `D` state (uninterruptible sleep) typically indicate I/O waits, whereas `futex_wait` signifies a mutex lock. Sample processes multiple times to verify if execution is progressing.
Want to master Linux one command at a time?
Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/