Hung process triage
This document describes tools and techniques for debugging hung processes on macOS (e.g. kickstart or deno not exiting).
1. Activity Monitor (GUI)
Section titled “1. Activity Monitor (GUI)”- Open Activity Monitor (Applications → Utilities)
- Find the process (e.g.
kickstartordeno) - Check CPU, Memory, and Threads tabs
- Use Inspect Process to see open files and network connections
2. lsof — list open files
Section titled “2. lsof — list open files”Shows files, sockets, and resources the process has open:
# Find the process ID firstps aux | grep kickstart
# List all open files/sockets for that PIDlsof -p <PID>
# Or in one command:lsof -p $(pgrep -f kickstart)Look for: open network connections (fetch calls), file handles that aren’t closed, pipes or sockets.
3. sample — process sampling
Section titled “3. sample — process sampling”Captures a stack trace of what the process is doing:
# Sample for 10 secondssample <PID> 10
# Or find and sample in one gosample $(pgrep -f kickstart) 10This shows where the process is stuck (function calls, waiting on I/O, etc.).
4. dtrace / dtruss — system call tracing
Section titled “4. dtrace / dtruss — system call tracing”Shows system calls the process is making:
# Trace system calls (requires sudo)sudo dtruss -p <PID>
# Or trace a specific process from startsudo dtruss -f ./kickstart <issue_url_or_number>Look for: select(), poll(), kevent() (waiting on I/O); network or file ops
that hang.
5. strace (if installed via Homebrew)
Section titled “5. strace (if installed via Homebrew)”Similar to dtruss but Linux-style:
brew install stracestrace -p <PID>6. vmmap — memory map
Section titled “6. vmmap — memory map”Shows memory regions and what’s mapped:
vmmap <PID>7. fs_usage — file system activity
Section titled “7. fs_usage — file system activity”Real-time file system operations:
sudo fs_usage -w -f filesys <PID>8. Network monitoring
Section titled “8. Network monitoring”Check if network calls are hanging:
# Show network connectionsnetstat -an | grep <PID>
# Or use lsof for networklsof -i -p <PID>Quick debugging script
Section titled “Quick debugging script”One-liner for comprehensive info:
PID=$(pgrep -f kickstart | head -1)echo "=== Process Info ==="ps -p $PID -o pid,ppid,command,etime,stateecho -e "\n=== Open Files/Sockets ==="lsof -p $PIDecho -e "\n=== Network Connections ==="lsof -i -p $PIDecho -e "\n=== Sampling (10 seconds) ==="sample $PID 10Most useful for hung processes
Section titled “Most useful for hung processes”If logs show completion but the process doesn’t exit, try in order:
lsof -p <PID>— Check for open network connections (fetch calls)sample <PID> 10— Stack trace to see what it’s waiting ondtruss -p <PID>— See if it’s stuck in a system call
The sample command is often the most useful—it shows the call stack and where
execution is stuck.
Example workflow
Section titled “Example workflow”# 1. Find the processps aux | grep kickstart
# 2. Get its PID (e.g. 12345)PID=12345
# 3. Check what it has openlsof -p $PID
# 4. Sample to see where it's stucksample $PID 10 > /tmp/sample-output.txt
# 5. Review the sample outputcat /tmp/sample-output.txt- Most commands require the process to still be running
sampleanddtrussmay slow the process slightly- Network-related hangs often show as open TCP connections in
lsof - If the process is waiting on I/O,
samplewill show it in aselect()orpoll()call