Path: 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 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 #include #include 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