Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

sky (1411)

sky
  (email not shown publicly)

sky on IRC

Journal of sky (1411)

Tuesday January 21, 2003
02:37 AM

flock != O_EXCL ?

[ #10094 ]
Reading the journal of brain d foy I noticed his filecounter entry where talks about using O_EXCL instead of flock. However I was under the impression O_EXCL is related to O_CREAT when the file exists, and should be used when you use rename() to get atomic operation at the filesystem level. In fact quoted fom perldoc -f open is the following.

In many systems the "O_EXCL" flag is available for opening files in exclusive mode. This is not locking: exclusiveness means here that if the file already exists, sysopen() fails. The "O_EXCL" wins "O_TRUNC".

So what is correct?

sky

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • You're right: O_EXCL only matters with O_CREAT. It guarantees (on a local filesystem, at least, don't expect anything on networked filesystems) that the open(2) fails (with errno == EEXIST) if a file by the specified name already exists. Nothing to do with locking, only to do with EXCLusive CREATion.
  • Yes, I am wrong.

    Thanks :)