Check what a process is blocking on using the CLI on Linux

  • Download Gist

Suppose I have blocking process blocking_process:

import os

os.system('rm -fr /tmp/pipe; mkfifo /tmp/pipe')
print len(open('/tmp/pipe').read())

On Linux, I might check what is it blocking on by doing:

$ strace -p $(pgrep -f blocking_process)
Process 5151 attached - interrupt to quit
open("/tmp/pipe", O_RDONLY ^C

If it were blocking on an incomplete system call with a file descriptor in it (i.e., read(3) I would do something like ls -l /proc/$(pgrep -f blocking_process)/fd/3 to know more about the file it's blocking on.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.