summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_pty.c
diff options
context:
space:
mode:
authorluoqi <luoqi@FreeBSD.org>1999-05-18 14:53:52 +0000
committerluoqi <luoqi@FreeBSD.org>1999-05-18 14:53:52 +0000
commit4e23e6eb166c98a130242db54491500f3d2ebce5 (patch)
tree24582947026ec2ebacaf781465495612ddcf822c /sys/kern/tty_pty.c
parenta2e0f6b31fd28f656616c6ce9712f164e419cdd2 (diff)
downloadFreeBSD-src-4e23e6eb166c98a130242db54491500f3d2ebce5.zip
FreeBSD-src-4e23e6eb166c98a130242db54491500f3d2ebce5.tar.gz
TIOCEXT is also inapproriate before the slave is open, return EAGAIN when
these ioctls are attempted. Move a misplaced comment. Pointed out by: Bruce
Diffstat (limited to 'sys/kern/tty_pty.c')
-rw-r--r--sys/kern/tty_pty.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 5cdb711..87f21f0 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
- * $Id: tty_pty.c,v 1.57 1999/05/08 06:39:43 phk Exp $
+ * $Id: tty_pty.c,v 1.58 1999/05/14 20:44:20 luoqi Exp $
*/
/*
@@ -649,32 +649,7 @@ ptyioctl(dev, cmd, data, flag, p)
register u_char *cc = tp->t_cc;
int stop, error;
- /*
- * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
- * ttywflush(tp) will hang if there are characters in the outq.
- */
- if (cmd == TIOCEXT) {
- /*
- * When the EXTPROC bit is being toggled, we need
- * to send an TIOCPKT_IOCTL if the packet driver
- * is turned on.
- */
- if (*(int *)data) {
- if (pti->pt_flags & PF_PKT) {
- pti->pt_send |= TIOCPKT_IOCTL;
- ptcwakeup(tp, FREAD);
- }
- tp->t_lflag |= EXTPROC;
- } else {
- if ((tp->t_lflag & EXTPROC) &&
- (pti->pt_flags & PF_PKT)) {
- pti->pt_send |= TIOCPKT_IOCTL;
- ptcwakeup(tp, FREAD);
- }
- tp->t_lflag &= ~EXTPROC;
- }
- return(0);
- } else if (devsw(dev)->d_open == ptcopen) {
+ if (devsw(dev)->d_open == ptcopen) {
switch (cmd) {
case TIOCGPGRP:
@@ -714,10 +689,10 @@ ptyioctl(dev, cmd, data, flag, p)
/*
* The rest of the ioctls shouldn't be called until
- * the slave is open. (Should we return an error?)
+ * the slave is open.
*/
if ((tp->t_state & TS_ISOPEN) == 0)
- return (0);
+ return (EAGAIN);
switch (cmd) {
#ifdef COMPAT_43
@@ -728,6 +703,11 @@ ptyioctl(dev, cmd, data, flag, p)
case TIOCSETA:
case TIOCSETAW:
case TIOCSETAF:
+ /*
+ * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
+ * ttywflush(tp) will hang if there are characters in
+ * the outq.
+ */
ndflush(&tp->t_outq, tp->t_outq.c_cc);
break;
@@ -744,6 +724,28 @@ ptyioctl(dev, cmd, data, flag, p)
return(0);
}
}
+ if (cmd == TIOCEXT) {
+ /*
+ * When the EXTPROC bit is being toggled, we need
+ * to send an TIOCPKT_IOCTL if the packet driver
+ * is turned on.
+ */
+ if (*(int *)data) {
+ if (pti->pt_flags & PF_PKT) {
+ pti->pt_send |= TIOCPKT_IOCTL;
+ ptcwakeup(tp, FREAD);
+ }
+ tp->t_lflag |= EXTPROC;
+ } else {
+ if ((tp->t_lflag & EXTPROC) &&
+ (pti->pt_flags & PF_PKT)) {
+ pti->pt_send |= TIOCPKT_IOCTL;
+ ptcwakeup(tp, FREAD);
+ }
+ tp->t_lflag &= ~EXTPROC;
+ }
+ return(0);
+ }
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error == ENOIOCTL)
error = ttioctl(tp, cmd, data, flag);
OpenPOWER on IntegriCloud