Interview Prep/Linux/Processes, memory and OOM

A command hangs forever, and `strace -p` shows it stuck on `futex(...)` or `read(3, ...)`. How do you dig in?

IntermediateTroubleshootingProcesses, memory and OOM
Answer

Likely causes → Waiting on a lock held by another thread (futex), or blocked reading from a pipe, socket or file that never delivers.

Diagnose →

ls -l /proc/<PID>/fd/3              # what is fd 3?
sudo lsof -p <PID> | grep ' 3'
sudo cat /proc/<PID>/stack
gdb -p <PID> -batch -ex 'thread apply all bt'   # if debuginfo is available

Fix → If it's a socket, check the remote end (DB, API). If it's a lock, find the thread holding it from the backtrace. Add timeouts in the code.

Prevent → Use timeouts for all network calls; capture thread dumps automatically on hang detection.

All Linux questions Roadmap: Linux

More on Processes, memory and OOM