How to get filename of an open file descriptor

Robert Watson rwatson at FreeBSD.org
Mon Nov 19 04:09:42 PST 2007


On Sun, 18 Nov 2007, Skip Ford wrote:

>>> 1)  procstat_args() doesn't use a local variable and the buffer doesn't
>>> get cleared between calls:
>>>
>>> $ procstat -a 797
>>> PID ARGS
>>> 797 audacious
>>> $ procstat -a 795 797
>>> PID ARGS
>>> 795 xterm -xtsessionID 11c0a80103000118536826300000007680000
>>> 797 audacious essionID 11c0a80103000118536826300000007680000
>>> $
>>>
>>> Other option's functions are not similarly affected.

Indeed, it turned out I fixed another related bug but not this bug (that if 
there was no pathname returned, we would print the previous pathname).  The 
bug here is not so much the buffer handling, but rather, that the termination 
condition for the printing loop was wrong.  I coded it to look for a 
double-nul, but in fact, I just needed to loop through until I hit the limit 
of the data returned by sysctl.  So this should now also be fixed.  I'm going 
going to hack a bit more on procstat today and then put up a new drop.

The main missing feature right now, from my perspective, is signal 
information, but are there other pieces of detailed process information we 
could usefully be displaying?  I'm not sure I want to get into teaching 
procinfo about generating stack traces, which is something the Solaris tools 
can do, but perhaps there are other things we could be displaying.

Although it occurs to me that, in many ways, it would be nice to be able to 
generate a kernel stack trace for each user thread--often when debugging a 
hung process, that's one of the pieces of information I'd really like to have, 
as just seeing a generic wchan sleep on a lock is not very useful.

Robert N M Watson
Computer Laboratory
University of Cambridge


More information about the freebsd-hackers mailing list