Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

(OT) Question on flock

by kprasanna_79 (Hermit)
on Oct 01, 2014 at 18:06 UTC ( [id://1102568]=perlquestion: print w/replies, xml ) Need Help??

kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

revered Monks

I am using a cloned version of UNIX. And when i apply flock on a file in a network its not working fine. It allows another program to modify the file. Can you please help me to lock the file in better way.

-Prasanna.K

Replies are listed 'Best First'.
Re: (OT) Question on flock
by Corion (Patriarch) on Oct 01, 2014 at 18:13 UTC

    Whether you're using a cloned version of UNIX or the real thing, file locking does not prevent another process from modifying the file. File locks on UNIXish operating systems are advisory. See flock(2). The documentation also documents that locking over NFS does not work.

    On Windows, you cannot overwrite a locked file. Maybe that is what you're thinking of?

      Thanks corion


      But our code was working earlier which all of the sudden after moved to the cloned version of unix it stopped working. When we debugged the code it stops at flock function. Is there any way we can overcome this. Need expert advise here.


      -Prasanna.K

        How does your question relate to Perl?

        I think communicating with your OS vendor is the more appropriate approach here. This site is for and about Perl, and not about obscure "UNIX clones".

        ... cloned version of unix ... Is there any way we can overcome this. Need expert advise here.

        Contact support :) fireup debugger/strace/...

Re: (OT) Question on flock
by Anonymous Monk on Oct 01, 2014 at 20:03 UTC

    As the documentation says, flocks are merely advisory, meaning they only work when all programs that access the file cooperate and use the same locking mechanism. Also, as Corion already noted, a lot of file locking mechanisms don't work properly over a lot of different network file systems.

    Why do you want to lock the files - are you trying to coordinate different processes of yours, or are you actually trying to prevent others from accessing the files?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-18 22:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found