diff options
author | bde <bde@FreeBSD.org> | 1995-07-31 21:02:00 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1995-07-31 21:02:00 +0000 |
commit | 6161be8527d8436daf7da9ba9caf28dd75239974 (patch) | |
tree | 6db12c5f3b7deb883374e9daa21609a9e76eaa85 /sys/kern/tty_pty.c | |
parent | fc2f9d98283b5feb3a2c1173667335cdc22e809b (diff) | |
download | FreeBSD-src-6161be8527d8436daf7da9ba9caf28dd75239974.zip FreeBSD-src-6161be8527d8436daf7da9ba9caf28dd75239974.tar.gz |
Obtained from: partly from ancient patches of mine via 1.1.5
Introduce TS_CONNECTED and TS_ZOMBIE states. TS_CONNECTED is set
while a connection is established. It is set while (TS_CARR_ON or
CLOCAL is set) and TS_ZOMBIE is clear. TS_ZOMBIE is set for on to
off transitions of TS_CARR_ON that occur when CLOCAL is clear and
is cleared for off to on transitions of CLOCAL. I/o can only occur
while TS_CONNECTED is set. TS_ZOMBIE prevents further i/o.
Split the input-event sleep address TSA_CARR_ON(tp) into TSA_CARR_ON(tp)
and TSA_HUP_OR_INPUT(tp). The former address is now used only for
off to on carrier transitions and equivalent CLOCAL transitions.
The latter is used for all input events, all carrier transitions
and certain CLOCAL transitions. There are some harmless extra
wakeups for rare connection- related events. Previously there were
too many extra wakeups for non-rare input events.
Drivers now call l_modem() instead of setting TS_CARR_ON directly
to handle even the initial off to on transition of carrier. They
should always have done this. l_modem() now handles TS_CONNECTED
and TS_ZOMBIE as well as TS_CARR_ON.
gnu/isdn/iitty.c:
Set TS_CONNECTED for first open ourself to go with bogusly setting
CLOCAL.
i386/isa/syscons.c, i386/isa/pcvt/pcvt_drv.c:
We fake carrier, so don't also fake CLOCAL.
kern/tty.c:
Testing TS_CONNECTED instead of TS_CARR_ON fixes TIOCCONS forgetting to
test CLOCAL. TS_ISOPEN was tested instead, but that broke when we disabled
the clearing of TS_ISOPEN for certain transitions of CLOCAL.
Testing TS_CONNECTED fixes ttyselect() returning false success for output
to devices in state !TS_CARR_ON && !CLOCAL.
Optimize the other selwakeup() call (this is not related to the other
changes).
kern/tty_pty.c:
ptcopen() can be declared in traditional C now that dev_t isn't short.
Diffstat (limited to 'sys/kern/tty_pty.c')
-rw-r--r-- | sys/kern/tty_pty.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 596e075..178082d 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tty_pty.c 8.2 (Berkeley) 9/23/93 - * $Id: tty_pty.c,v 1.14 1995/07/22 01:30:32 bde Exp $ + * $Id: tty_pty.c,v 1.15 1995/07/22 16:45:08 bde Exp $ */ /* @@ -132,7 +132,7 @@ ptsopen(dev, flag, devtype, p) } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) return (EBUSY); if (tp->t_oproc) /* Ctrlr still around. */ - tp->t_state |= TS_CARR_ON; + (void)(*linesw[tp->t_line].l_modem)(tp, 1); while ((tp->t_state & TS_CARR_ON) == 0) { if (flag&FNONBLOCK) break; @@ -268,17 +268,11 @@ ptcwakeup(tp, flag) } } -/*ARGSUSED*/ -#ifdef __STDC__ -int -ptcopen(dev_t dev, int flag, int devtype, struct proc *p) -#else int ptcopen(dev, flag, devtype, p) dev_t dev; int flag, devtype; struct proc *p; -#endif { register struct tty *tp; struct pt_ioctl *pti; @@ -309,7 +303,19 @@ ptcclose(dev) tp = &pt_tty[minor(dev)]; (void)(*linesw[tp->t_line].l_modem)(tp, 0); - tp->t_state &= ~TS_CARR_ON; + + /* + * XXX MDMBUF makes no sense for ptys but would inhibit the above + * l_modem(). CLOCAL makes sense but isn't supported. Special + * l_modem()s that ignore carrier drop make no sense for ptys but + * may be in use because other parts of the line discipline make + * sense for ptys. Recover by doing everything that a normal + * ttymodem() would have done except for sending a SIGHUP. + */ + tp->t_state &= ~(TS_CARR_ON | TS_CONNECTED); + tp->t_state |= TS_ZOMBIE; + ttyflush(tp, FREAD | FWRITE); + tp->t_oproc = 0; /* mark closed */ tp->t_session = 0; return (0); @@ -357,7 +363,7 @@ ptcread(dev, uio, flag) if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) break; } - if ((tp->t_state&TS_CARR_ON) == 0) + if ((tp->t_state & TS_CONNECTED) == 0) return (0); /* EOF */ if (flag & IO_NDELAY) return (EWOULDBLOCK); @@ -411,7 +417,7 @@ ptcselect(dev, rw, p) struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; int s; - if ((tp->t_state&TS_CARR_ON) == 0) + if ((tp->t_state & TS_CONNECTED) == 0) return (1); switch (rw) { @@ -511,7 +517,7 @@ again: while (cc > 0) { if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 && (tp->t_canq.c_cc > 0 || !(tp->t_iflag&ICANON))) { - wakeup(TSA_CARR_ON(tp)); + wakeup(TSA_HUP_OR_INPUT(tp)); goto block; } (*linesw[tp->t_line].l_rint)(*cp++, tp); @@ -526,7 +532,7 @@ block: * Come here to wait for slave to open, for space * in outq, or space in rawq. */ - if ((tp->t_state&TS_CARR_ON) == 0) + if ((tp->t_state & TS_CONNECTED) == 0) return (EIO); if (flag & IO_NDELAY) { /* adjust for data copied in but not written */ |