Index: sys/kern/tty.c =================================================================== --- sys/kern/tty.c +++ sys/kern/tty.c @@ -1930,6 +1930,7 @@ return (0); case TIOCSTART: tp->t_flags &= ~TF_STOPPED; + tp->t_termios.c_lflag &= ~FLUSHO; ttydevsw_outwakeup(tp); ttydevsw_pktnotify(tp, TIOCPKT_START); return (0); Index: sys/kern/tty_ttydisc.c =================================================================== --- sys/kern/tty_ttydisc.c +++ sys/kern/tty_ttydisc.c @@ -474,6 +474,11 @@ MPASS(oblen == 0); + if (CMP_FLAG(l, FLUSHO)) { + uio->uio_resid = 0; + return (0); + } + /* Step 1: read data. */ obstart = ob; nlen = MIN(uio->uio_resid, sizeof ob); @@ -495,6 +500,11 @@ do { unsigned int plen, wlen; + if (CMP_FLAG(l, FLUSHO)) { + uio->uio_resid = 0; + return (0); + } + /* Search for special characters for post processing. */ if (CMP_FLAG(o, OPOST)) { plen = ttydisc_findchar(obstart, oblen); @@ -629,6 +639,9 @@ ttydisc_echo_force(struct tty *tp, char c, int quote) { + if (CMP_FLAG(l, FLUSHO)) + return 0; + if (CMP_FLAG(o, OPOST) && CTL_ECHO(c, quote)) { /* * Only perform postprocessing when OPOST is turned on @@ -906,6 +919,17 @@ tp->t_flags |= TF_LITERAL; return (0); } + /* Discard processing */ + if (CMP_CC(VDISCARD, c)) { + if (CMP_FLAG(l, FLUSHO)) { + tp->t_termios.c_lflag &= ~FLUSHO; + } else { + tty_flush(tp, FWRITE); + ttydisc_echo(tp, c, 0); + // XXX netbsd does retype, should we? XXX + tp->t_termios.c_lflag |= FLUSHO; + } + } } /*