[comp.unix.questions] How to make a tty un'open

cs00chs@unccvax.uncc.edu (charles spell) (09/10/90)

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.


It seems like there would be an easy way via ioctl(). I would like to
know how to do this on a pyramid 9815 even if it is not portable.
-- 
.--------------------------.  ...  |On the border of your mind lies a place
|uunet!mcnc!unccvax!cs00chs|  (")  |where dreams and reality are one...I will 
`--------------------------'-w-U-w-|take you there, for I am the subject...
\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\|the subject of your imagination. -Aldo Nova

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (09/12/90)

In article <2699@unccvax.uncc.edu> cs00chs@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, dhe optimal way would be for ttys not to be in the filesystem in the
first place.

My pdy 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

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (09/12/90)

In article <2699@unccvax.uncc.edu> cs00chs@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

rns@se-sd.SanDiego.NCR.COM (Rick Schubert) (09/18/90)

In <2699@unccvax.uncc.edu> cs00chs@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.

Wouldn't `chmod(0)' do the trick (make sure you change it back when you
are through, though)?

-- Rick Schubert (rns@se-sd.sandiego.NCR.COM)