Unix Programming - How2 find all files used by proc & kids?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2007 > How2 find all files used by proc & kids?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How2 find all files used by proc & kids?
kj

2007-12-16, 1:26 pm




Is there a way to determine all the files that are accessed by a
process and its children? (I'm aware of lsof, but as far as I
know, it will only give a snapshot of open files; even if I were
to put a call to lsof in a loop, I'm sure this would miss many
files that are open for a very short time.) Is there a utility
for performing this kind of analysis?

(In case it matters, the flavor of Unix I'm most interested to do
this in is Darwin.)

TIA!

kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
fjblurt@yahoo.com

2007-12-16, 1:26 pm

On Dec 16, 9:03 am, kj <so...@987jk.com.invalid> wrote:
> Is there a way to determine all the files that are accessed by a
> process and its children? (I'm aware of lsof, but as far as I
> know, it will only give a snapshot of open files; even if I were
> to put a call to lsof in a loop, I'm sure this would miss many
> files that are open for a very short time.) Is there a utility
> for performing this kind of analysis?
>
> (In case it matters, the flavor of Unix I'm most interested to do
> this in is Darwin.)


You could use something like truss(1) and look for calls to open(2).
It is theoretically able to follow forks, so you can trace child
processes too, but in practice there are some snags. Of course, this
is only suitable for debugging purposes; I hope this isn't going to be
part of a real program.
Ian Collins

2007-12-16, 1:26 pm

kj wrote:
> Is there a way to determine all the files that are accessed by a
> process and its children? (I'm aware of lsof, but as far as I
> know, it will only give a snapshot of open files; even if I were
> to put a call to lsof in a loop, I'm sure this would miss many
> files that are open for a very short time.) Is there a utility
> for performing this kind of analysis?
>
> (In case it matters, the flavor of Unix I'm most interested to do
> this in is Darwin.)
>

DTrace is your friend!

--
Ian Collins.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com