Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: •Re: Re: Order of flock and open

by ferrency (Deacon)
on Apr 30, 2003 at 20:20 UTC ( [id://254453]=note: print w/replies, xml ) Need Help??


in reply to •Re: Re: Order of flock and open
in thread Order of flock and open

My experiences are probably platform-dependant on FreeBSD. However, those experiences offer empirical evidence that on my preferred platform, opening the file for write a second time opens the same file, not a new file, and subsequent lock attempts on the write filehandle fail.

Example:

% perl -MFcntl -e 'open my $f, "<foofile"; flock $f, LOCK_EX; open my +$g, ">foofile"; flock $g, LOCK_EX|LOCK_NB or die "No lock\n";' + No lock %
In summary: please don't follow my original advice. Merlyn is probably right in the general case, and will probably even find a good explanation as to why I've fooled myself into believing what I do. I'll add a caveat to the particular portion of my brain which holds this information, but I'm unlikely to erase it completely :)

Alan

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found