Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Is file still open ?

by Thelonius (Priest)
on May 15, 2006 at 13:09 UTC ( [id://549483]=note: print w/replies, xml ) Need Help??


in reply to Is file still open ?

Your LOCK_EX is probably failing because you only have the file opened for reading. Some operating systems require you to have the file open for writing to do LOCK_EX. But, as cdarke notes, locking won't tell you anything unless the other process is locking, too.

Some versions of Unix (and Linux) support the fuser command. FreeBSD has the fstat command. On some versions of Unix, there's no way to tell!

On most (I think all) Unixes, you can kill(pid, 0) to see if pid exists.

Replies are listed 'Best First'.
Re^2: Is file still open ?
by blazar (Canon) on May 15, 2006 at 13:18 UTC

    It's important to stress that the fuser command, just like Linux::Fuser (worth pointing out, anyway!) just inspects the /proc filesystem to find out. I.e. there's not a "direct" record of the processes that are holding a certain file open. The relation that is actually remembered is the inverse one...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://549483]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-25 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found