strace -p: Attach to a Hung Process
strace -p <pid> attaches to a live process and streams its system calls, so you can see what a stuck CI step is waiting on.
A job that produces no output and never finishes is usually blocked in one syscall. Attaching with strace -p names that syscall without killing the process.
What it does
strace -p attaches to an existing PID via ptrace and prints its ongoing syscalls until you press Ctrl-C, which detaches cleanly. Combined with -f it also follows threads and children. This is non-destructive: detaching leaves the process running.
Common usage
# find the hung PID, then watch it
ps aux | grep '[t]est-runner'
strace -f -p 4242
# attach with timestamps to see where time goes
strace -tt -T -p 4242Options
| Flag | What it does |
|---|---|
| -p <pid> | Attach to a running process |
| -f | Also trace its threads and children |
| -tt | Prefix each line with a microsecond timestamp |
| -T | Show wall time spent inside each syscall |
| -e trace=<set> | Limit which syscalls are shown |
In CI
In an interactive debug session on a runner, attach to the stuck PID. A repeating futex(... is lock contention or a deadlock; epoll_wait( or poll( is a network wait (often a hung HTTP call); wait4( means it is blocked on a child that never exits. That single syscall usually points straight at the bug.
Common errors in CI
"strace: attach: ptrace(PTRACE_SEIZE, 4242): Operation not permitted" comes from the Yama ptrace_scope hardening or a missing SYS_PTRACE capability; set /proc/sys/kernel/yama/ptrace_scope to 0 or add the capability. "strace: attach: ptrace(...): No such process" means the PID already exited. Attaching as a different user than the target needs sudo.