Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying file causing hang from strace

I have a GTK program running on Ubuntu 10.04 that hangs in interruptible state, and I'd like to understand the output of strace. In particular, I have this line:

read(5, 0x2ba9ac4, 4096) = -1 EAGAIN (Resource temporarily unavailable)

I suspect 5 is the file descriptor, 0x2ba9ac4 the address in this file to be read, and 4096 the amount of data to read. Can you confirm? More importantly, how can one determine which file the program is trying to read? This file descriptor does not exist in /proc/pid/fd (which is probably why the program hangs).

like image 739
Greg Avatar asked Mar 04 '11 13:03

Greg


1 Answers

You can find which file uses this file descriptor by calling strace -o log -eopen,read yourprogram. Then search in the log file the call to read of interest. From this line (and not from the first line of the file), search upwards the first occurrence of this file descriptor (returned by a call to open).

For example here, the file descriptor returned by open is 3:

open("/etc/ld.so.cache", O_RDONLY)      = 3
like image 178
liberforce Avatar answered Sep 23 '22 15:09

liberforce