Article View: comp.bugs.sys5
Article #903O_EXCL flag on open of character tty device.
From: Frank Glass
Date: Mon, 07 Nov 1988 22:11
Date: Mon, 07 Nov 1988 22:11
37 lines
1528 bytes
1528 bytes
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
Technical Details
Message-ID:
<1464@holos0.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!bionet!apple!rutgers!mit-eddie!bbn!gatech!dcatla!holos0!fsgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!bionet!apple!rutgers!mit-eddie!bbn!gatech!dcatla!holos0!fsg From: fsg@holos0.UUCP (Frank Glass) Newsgroups: comp.bugs.sys5 Subject: O_EXCL flag on open of character tty device. Message-ID: <1464@holos0.UUCP> Date: 7 Nov 88 22:11:44 GMT Reply-To: fsg@holos0.UUCP (Frank Glass) Distribution: na Organization: Holos Software, Atlanta Lines: 36