Strace -p with number of lines of context/history

strace

I'd like to strace a running process, which I know I can do with strace -p <pid>, but I believe the process has hung on some blocking call, e.g. sem_wait() on a semaphore that's never posted, etc., and the output of strace is only one line, like:

Process 195 attached - interrupt to quit
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}], 2, 3600000^C <unfinished ...>

Is it possible to specify strace to output more lines of context/history? I'm guessing not, because I'm guessing strace ouputs realtime and per function/instruction, but I thought I'd ask to confirm.

Best Answer

You are correct, there is no history available.

In case it is not obvious, the output shows that the process is in a poll call, waiting for input from file descriptors 3 and 6. Running ls -l /proc/195/fd should show what these descriptors are connected to.

Related Question