Saturday, 16 August 2014

Finding the file or device pointed to by a file descriptor

I had been noticing that Firefox starts off with around 400mb and reaches around 1.4 gb as I keep using it throughout the day. Also, CPU utilization clocked at 25% on my i7. So, I thought of trying to mess around in the hope of finding something interesting. I found the pid using the following.

ps aux | grep firefox

I ran an strace to try and see what was keeping it so busy.

strace -p <pid_of_firefox_process>

This is what I got.

poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
getrusage(RUSAGE_SELF, {ru_utime={17387, 398261}, ru_stime={821, 999917}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={17387, 438261}, ru_stime={821, 999917}, ...}) = 0
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
write(18, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])

Now, I wanted to know the files pointed to by file descriptors 4, 5, 17, 19. To look those use, I read that I can use /proc filesystem. So, I just tried simply looking it up there.

ls -l /proc/<pid_of_firefox_process>/fd

The files turned out to be as follows:
  • 4 - a socket
  • 5 - anon_inode:[eventfd]
  • 17 - a pipe
  • 19 - another socket
Any suggestions are welcome. I will keep looking into the issue.

No comments: