Re: How do I ask: How many processes have this file open now?

Marty Leisner (leisner@sdsp.mc.xerox.com)
Wed, 27 May 1998 10:46:56 PDT


> David Woodhouse <Dave@imladris.demon.co.uk> writes:
>
> > russ@taylor.digex.net said:
> > > Is there a system call for a user program that will, given a filename
> > > (or fd), return the number of processes with that file open?
> >
> > Not AFAIK.
> > fuser(1) does it by parsing all the cwd, fd, maps etc. entries in /proc
>
> You might also want to take a look at lsof(1), which does everything
> fuser does and more, all in user space (taking full advantage of
> /proc; I don't think it has to resort to kmem on Linux.). Note that
> Red Hat ships fuser but not lsof, so you may need to track it down.
>
> --
>
lsof uses /proc on late 2.1, kmem on everything else.

I really think its a useful program...
ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/lsof.tar.gz

-- 
marty
leisner@sdsp.mc.xerox.com  
The Feynman problem solving Algorithm
        1) Write down the problem
        2) Think real hard
        3) Write down the answer
                Murray Gell-mann in the NY Times

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu