Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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

by ferrency (Deacon)
on Apr 30, 2003 at 20:20 UTC ( #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.


% 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 :)


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2019-11-19 08:32 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (94 votes). Check out past polls.