How determine if a file is opened by another process

Tom Christiansen tchrist at convex.COM
Tue Feb 5 15:53:52 AEST 1991


>From the keyboard of craft at uts.amdahl.com (Peter Craft):
:In article <1969 at winnie.fit.edu>, rrandall at zach.fit.edu (Rick Randall) writes:
:> In article <1991Jan29.204403.6071 at rick.doc.ca> andrew at calvin.doc.ca (Andrew Patrick) writes:
:> >In article <1488 at nixsin.UUCP> koerber.sin at nixdorf.com writes:
:> >
:> >>I want to find out, whether any process has opened a file, of which I only
:> >>Could anyone pls give me a hint ?. Maybe it's in a table in the kernel ?
:> >
:> >I need to know this too!
:> >
:> 
:> 	ANSWER:  man fuser
:
:fuser will give you the PID's which have a particular file open.

[only if you should have it on your system.]

:
:Does anyone know of a similar facility which will list the files that
:a particular process has open.  If not, does anyone have any simple 
:suggestions on how to accomplish this task, (short of formatting the 
:user structure..).

fstat(8), a standard utility out of the BSD release (um, 4.3 something)
goes both ways.  You can hand it files and learn about processes they have
open, or you can hand it procs (or users) and get back files.  It helps
for pulling out PCB addrs on sockets, which when used with netstat(8) can
sometimes be useful.  It can tell you what files are open on a partition
and other interesting things.

I believe it's on uunet.    Of course, it's pretty kernel specific.

--tom
--
"Still waiting to read alt.fan.dan-bernstein using DBWM, Dan's own AI
window manager, which argues with you 10 weeks before resizing your window." 
### And now for the question of the month:  How do you spell relief?   Answer:
U=brnstnd at kramden.acf.nyu.edu; echo "/From: $U/h:j" >>~/News/KILL; expire -f $U



More information about the Comp.unix.questions mailing list