Why lsof shows the file as open and fstat doesn't ?

Dan Nelson dnelson at allantgroup.com
Mon Feb 15 15:48:12 UTC 2010


In the last episode (Feb 15), Yuri said:
> I am looking at one file which is actually a unix socket: 
> /tmp/dbus-iQmkLjgxD6.
> "lsof | grep dbus-iQmkLjgxD6" shows that it's open by a particular 
> process many times:
> ibus-daem 48407       yuri    4u    unix 0xc966019c  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri    5u    unix 0xc9569000  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri    6u    unix 0xc955e9a8  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri    7u    unix 0xc8d25000  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri    8u    unix 0xc9596ce0  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri    9u    unix 0xc8f9b19c  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri   10u    unix 0xc916619c  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri   11u    unix 0xc9547338  0t0  /tmp/dbus-iQmkLjgxD6
> ibus-daem 48407       yuri   12u    unix 0xc9589670  0t0  /tmp/dbus-iQmkLjgxD6
> 
> But when I run "fstat /tmp/dbus-iQmkLjgxD6" it doesn't return anything, 
> like this file isn't open at all.
> 
> Why there is such discrepancy?

It looks like fstat doesn't work on unix sockets at all; I tried on
/tmp/mysql.sock and some X11 sockets.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list