[comp.lang.c] what does O_EXCL open flag do?

martin@clubmed.hf.intel.com.ogc.edu (12/30/89)

Does anyone know what the O_EXCL flag for the open call is
supposed to do?  I have read the POSIX spec, but I don't quite
understand what the flag is for.  The only thing that
the POSIX spec says is that if O_EXCL and O_CREAT are set, open()
shall fail if the file exists.  What if just O_EXCL is set?

You can mail to me directly or post a followup...

Thanks...

                          
                  _/_          |
 ______  __.  __  /  o ____    |  textronix!reed!littlei!zeus:martin
/ / / <_(_/|_/ (_<__<_/ / <    |
                               |  martin@clubmed.hf.intel.com
                               |

lm@snafu.Sun.COM (Larry McVoy) (12/30/89)

In article <479@dios.hf.intel.com> martin@clubmed.hf.intel.com (Martin Wilde) writes:
>Does anyone know what the O_EXCL flag for the open call is
>supposed to do?  I have read the POSIX spec, but I don't quite
>understand what the flag is for.  The only thing that
>the POSIX spec says is that if O_EXCL and O_CREAT are set, open()
>shall fail if the file exists.  What if just O_EXCL is set?

Yeah, it's a misnomer.  As far as I know, it's only generic use is the one
you describe (commonly used to implement a crude form of semaphore).

I think that some device drivers may also look at this flag to mean exclusive 
(i.e, one user).  
---
What I say is my opinion.  I am not paid to speak for Sun, I'm paid to hack.

Larry McVoy, Sun Microsystems     (415) 336-7627       ...!sun!lm or lm@sun.com