|
Prev: Question on ACE 's alternative and distributed computing?
Next: what is Delivered-To: user:X.com@Y.com
From: Gamitech on 17 Jul 2008 11:08 Hello all, I am new here. I have a question, how can you tell if a file has an opened handle (or is already in use) by a process. I want to do it without having to write a device driver, or something fancy. Thanks.
From: Maxim Yegorushkin on 17 Jul 2008 12:17 On Jul 17, 4:08 pm, Gamit...(a)gmail.com wrote: > I have a question, how can you tell if a file has an opened handle (or > is already in use) by a process. I want to do it without having to > write a device driver, or something fancy. May be http://en.wikipedia.org/wiki/Fuser_(Unix) ? Max
From: Ralf Becker on 17 Jul 2008 15:10 Gamitech(a)gmail.com wrote: > Hello all, I am new here. > I have a question, how can you tell if a file has an opened handle (or > is already in use) by a process. I want to do it without having to > write a device driver, or something fancy. The commands "fstat" or "lsof" are on most Unix systems readily available. -- Ralf Becker ralf(a)akk.org Arbeitskreis Kultur und Kommunikation / Universitaet Karlsruhe Paulckeplatz 1 76131 Karlsruhe Tel 0721/96403-22 Fax 0721/608-4019 --------------------
From: Gordon Burditt on 17 Jul 2008 16:43 >I have a question, how can you tell if a file has an opened handle (or >is already in use) by a process. I want to do it without having to >write a device driver, or something fancy. By the time you get the answer, it will be out of date, unless you go for something that will also PREVENT further opens (file locking). This is especially true when you have to invoke a setuid-root or setgid-something process like fstat or lsof and then look through the output for something you want.
From: fjblurt on 20 Jul 2008 18:56
On Jul 17, 8:08 am, Gamit...(a)gmail.com wrote: > Hello all, I am new here. > I have a question, how can you tell if a file has an opened handle (or > is already in use) by a process. I want to do it without having to > write a device driver, or something fancy. Why do you need this information? For debugging purposes, look at utilities like lsof or fuser. For use in a program, you probably don't really want to do this :) For one thing, it is difficult to do in a portable fashion. For another, designs which use this information are generally flawed, because some other program could open the file immediately after you check. |