Article View: comp.bugs.sys5
Article #905Re: O_EXCL flag on open of character tty device.
From: Dan Mercer
Date: Tue, 08 Nov 1988 19:28
Date: Tue, 08 Nov 1988 19:28
44 lines
1837 bytes
1837 bytes
In article <1464@holos0.UUCP> fsg@holos0.UUCP (Frank Glass) writes:
:
: 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?
:
:--------------------cut here----------------------------
:#include <termio.h>
:#include <fcntl.h>
:#include <stdio.h>
:main(argc,argv)
:{
: int ii;
: char *tty_id = "/dev/tty00"; /* arbitrary tty choice */
:
: ii = open(tty_id,O_WRONLY|O_NDELAY|O_EXCL);
: if(ii<0) {
: fprintf(stderr,"First open attempt, ");
: perror(tty_id);
: exit(1);
: }
: ii = open(tty_id,O_WRONLY|O_NDELAY|O_EXCL);
: if(ii<0) {
: fprintf(stderr,"Second open attempt, ");
: perror(tty_id);
: exit(1);
: }
: fprintf(stderr,"Opened %s with no errors, O_EXCL a mystery.\n",tty_id);
:}
:--
:Frank Glass
:Holos Software, Inc.
:Voice: (404) 496-1358
:UUCP: ...!gatech!holos0!fsg
Don't be fooled by the term exclusive. The only documentation I found
indicates that the flag must be used with O_CREAT, and failure depends
not on whether the file is open, but whether it already exists.
Dan Mercer
NCR Comten
Technical Details
Message-ID:
<875@ncrcce.StPaul.NCR.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!ncrlnk!ncrcce!mercerReferences:
<1464@holos0.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ncrlnk!ncrcce!mercer From: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) Newsgroups: comp.bugs.sys5 Subject: Re: O_EXCL flag on open of character tty device. Message-ID: <875@ncrcce.StPaul.NCR.COM> Date: 8 Nov 88 19:28:11 GMT References: <1464@holos0.UUCP> Reply-To: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) Distribution: na Organization: NCR Comten, Inc. Lines: 44