🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #913

Re: O_EXCL flag on open of character tty device.

#913
From: Brandon S. Allbery
Date: Mon, 14 Nov 1988 22:53
32 lines
2172 bytes
As quoted from <1464@holos0.UUCP> by fsg@holos0.UUCP (Frank Glass):
+---------------
| 	My understanding from the manuals is that the O_EXCL flag can
| be used to exclusively open a device.  The following code works
| as I expect on an AT&T 6386 in that the first open fails if a process
| (like getty, for example) has tty00 open, otherwise the second open
| fails.  Contrary to my expectation, _both_ opens succeed on the 3b2,
| the NCR Tower, and a variety of other System V things.  Do I not
| understand the documentation?
+---------------

Unless O_EXCL has undergone considerable revision since System V Release 2,
you've got a misunderstanding.

(1) O_EXCL only works with O_CREAT; it is ignored otherwise.
(2) Its function is to insure that a file does NOT exist before its creation.
    This is used to allow for atomic lockfile creation:  there is no window
    of vulnerability between the check for the file's existence and its
    creation, so no race condition can result in two or more processes
    creating the file at the same time.

It is possible that System V.3.2 has decided to overload O_EXCL to mean the
same thing as BSD's TIOCEXCL, i.e. exclusive use of a tty device.  But I'm
almost certain that the 3b2 and NCR Tower have the original semantics.

++Brandon
-- 
Brandon S. Allbery, comp.sources.misc moderator and one admin of ncoast PA UN*X
uunet!hal.cwru.edu!ncoast!allbery  <PREFERRED!>	    ncoast!allbery@hal.cwru.edu
allberyb@skybridge.sdi.cwru.edu	      <ALSO>		   allbery@uunet.uu.net
comp.sources.misc is moving off ncoast -- please do NOT send submissions direct
      Send comp.sources.misc submissions to comp-sources-misc@<backbone>.
Technical Details
Message-ID: <13090@ncoast.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!mailrus!cwjcc!hal!ncoast!allbery
References: <1464@holos0.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!mailrus!cwjcc!hal!ncoast!allbery
From: allbery@ncoast.UUCP (Brandon S. Allbery)
Newsgroups: comp.bugs.sys5
Subject: Re: O_EXCL flag on open of character tty device.
Message-ID: <13090@ncoast.UUCP>
Date: 14 Nov 88 22:53:38 GMT
References: <1464@holos0.UUCP>
Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery)
Followup-To: comp.bugs.sys5
Distribution: na
Organization: Cleveland Public Access UN*X, Cleveland, Oh
Lines: 32