How to make a tty un'open(2)'able after another process opens it

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Sep 12 05:31:01 AEST 1990


In article <2699 at unccvax.uncc.edu> cs00chs at unccvax.uncc.edu (charles spell) writes:
> Is there a way (besides lock files) that I can set a /dev/tty* to be
> unopenable by other processes once it is opened by a process? The optimal
> way would be for open() to return -1 if the tty is already being used.

No, the optimal way would be for ttys not to be in the filesystem in the
first place.

My pty package (BSD variants only) includes PD ``exclon'' and
``excloff'' to turn exclusive use on and off for a tty. Look up the
TIOCEXCL ioctl. You may or may not consider it a bug that this also
stops controlling terminal access through /dev/tty.

---Dan



More information about the Comp.unix.questions mailing list