Re: What is O_EXCL short for?



On Tue, 26 Dec 2006 14:39:06 +0000 Måns Rullgård <mru@xxxxxxxxxxxxx> wrote:
| Ronald <followait@xxxxxxx> writes:
|
|> I don't understand why is it used with O_CREAT. Because a file can't
|> be created then.
|
| I believe it stands for "exclusive". It only makes sense together
| with O_CREAT, where its effect is to create the file only if it
| doesn't already exist. This is useful to avoid race conditions
| between several processes trying to create the same file, often a lock
| file.

The correct wording would be that it doesn't open the file if it
already exists. With your wording, if the file already exists it
could go ahead and open it but just not create it. But that would
not be of much value to have an option for as that is the default
behaviour with O_CREAT alone.
.