Identification of strace-freezing file

I have a GTK program running on Ubuntu 10.04 that hangs in an interrupt state and I would like to understand the strace output. In particular, I have this line:

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

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

+4
source share
3 answers

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

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

 open("/etc/ld.so.cache", O_RDONLY) = 3 
+8
source

The second argument to read() is just the destination pointer, which requests reading from file descriptor 5 and a maximum of 4096 bytes. See the manual page for read() .

0
source

By adding an answer to @liberforce if the process is already running, you can get the file name using lsof

form strace

 [pid 7529] read(102, 0x7fedc64c2fd0, 16) = -1 EAGAIN (Resource temporarily unavailable) 

Now that lsof

 lsof -p 7529 | grep 102 java 7529 luis 102u 0000 0,9 0 9178 anon_inode 
0
source

Source: https://habr.com/ru/post/1342292/


All Articles