What is O_EXCL short for? - Linux

This is a discussion on What is O_EXCL short for? - Linux ; I don't understand why is it used with O_CREAT. Because a file can't be created then....

+ Reply to Thread
Results 1 to 3 of 3

Thread: What is O_EXCL short for?

  1. What is O_EXCL short for?

    I don't understand why is it used with O_CREAT. Because a file can't be
    created then.

  2. Re: What is O_EXCL short for?

    Ronald 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.

    --
    Måns Rullgård
    mru@inprovide.com

  3. Re: What is O_EXCL short for?

    On Tue, 26 Dec 2006 14:39:06 +0000 Måns Rullgård wrote:
    | Ronald 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.

+ Reply to Thread