[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: opening twice with O_RDWR

Subject: Re: opening twice with O_RDWR
Date: Sun, 31 Dec 2006 13:18:46 -0500
User-agent: Pan/ (As She Crawled Across the Table)

On Sun, 31 Dec 2006 06:28:46 -0800, Paul Pluzhnikov wrote:

> Mike - EMAIL IGNORED <> writes:
>> In the code fragment below, I would have expected a
>> failure on the second open,
> Why would you expect that?
>> I would like to generate a failure.  How can I do this?
> Use O_EXCL (which exists *just* for that purpose).
>> The file is usually, but not always
>> present before the program is run.

I think not. From man 2 open:

   O_EXCL When used with O_CREAT, if the file  already  exists  it  is  an
          error  and  the open will fail. In this context, a symbolic
          link exists, regardless of where its points to.  

Since in my case, a preexisting file does not mean a failure, this
will not serve unless I use a second "locking file".  I quick test
has verified this. If, in the above, the word "exists" were changed
to "opened", my purpose would be served.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]