From owner-svn-src-all@freebsd.org Thu Aug 27 05:11:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 671EA3C6DE9; Thu, 27 Aug 2020 05:11:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BcW6D27ZGz47yK; Thu, 27 Aug 2020 05:11:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2DF1F1EC44; Thu, 27 Aug 2020 05:11:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07R5BGdo093767; Thu, 27 Aug 2020 05:11:16 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07R5BFJm093764; Thu, 27 Aug 2020 05:11:15 GMT (envelope-from imp@FreeBSD.org) Message-Id: <202008270511.07R5BFJm093764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 27 Aug 2020 05:11:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364855 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 364855 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2020 05:11:16 -0000 Author: imp Date: Thu Aug 27 05:11:15 2020 New Revision: 364855 URL: https://svnweb.freebsd.org/changeset/base/364855 Log: Implement FLUSHO Turn FLUSHO on/off with ^O (or whatever VDISCARD is). Honor that to throw away output quickly. This tries to remain true to 4.4BSD behavior (since that was the origin of this feature), with any corrections NetBSD has done. Since the implemenations are a little different, though, some edge conditions may be handled differently. Reviewed by: kib, kevans Differential Review: https://reviews.freebsd.org/D26148 Modified: head/sys/kern/tty.c head/sys/kern/tty_ttydisc.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Thu Aug 27 03:50:34 2020 (r364854) +++ head/sys/kern/tty.c Thu Aug 27 05:11:15 2020 (r364855) @@ -1467,6 +1467,7 @@ tty_signal_sessleader(struct tty *tp, int sig) /* Make signals start output again. */ tp->t_flags &= ~TF_STOPPED; + tp->t_termios.c_lflag &= ~FLUSHO; if (tp->t_session != NULL && tp->t_session->s_leader != NULL) { p = tp->t_session->s_leader; @@ -1486,6 +1487,7 @@ tty_signal_pgrp(struct tty *tp, int sig) /* Make signals start output again. */ tp->t_flags &= ~TF_STOPPED; + tp->t_termios.c_lflag &= ~FLUSHO; if (sig == SIGINFO && !(tp->t_termios.c_lflag & NOKERNINFO)) tty_info(tp); @@ -1930,6 +1932,7 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *da 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); Modified: head/sys/kern/tty_ttydisc.c ============================================================================== --- head/sys/kern/tty_ttydisc.c Thu Aug 27 03:50:34 2020 (r364854) +++ head/sys/kern/tty_ttydisc.c Thu Aug 27 05:11:15 2020 (r364855) @@ -95,6 +95,7 @@ ttydisc_close(struct tty *tp) /* Clean up our flags when leaving the discipline. */ tp->t_flags &= ~(TF_STOPPED|TF_HIWAT|TF_ZOMBIE); + tp->t_termios.c_lflag &= ~FLUSHO; /* * POSIX states that we must drain output and flush input on @@ -474,6 +475,12 @@ ttydisc_write(struct tty *tp, struct uio *uio, int iof MPASS(oblen == 0); + if (CMP_FLAG(l, FLUSHO)) { + uio->uio_offset += uio->uio_resid; + uio->uio_resid = 0; + return (0); + } + /* Step 1: read data. */ obstart = ob; nlen = MIN(uio->uio_resid, sizeof ob); @@ -495,6 +502,12 @@ ttydisc_write(struct tty *tp, struct uio *uio, int iof do { unsigned int plen, wlen; + if (CMP_FLAG(l, FLUSHO)) { + uio->uio_offset += uio->uio_resid; + 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 +642,9 @@ static int 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 @@ -879,8 +895,10 @@ ttydisc_rint(struct tty *tp, char c, int flags) } /* Allow any character to perform a wakeup. */ - if (CMP_FLAG(i, IXANY)) + if (CMP_FLAG(i, IXANY)) { tp->t_flags &= ~TF_STOPPED; + tp->t_termios.c_lflag &= ~FLUSHO; + } /* Remove the top bit. */ if (CMP_FLAG(i, ISTRIP)) @@ -905,6 +923,18 @@ ttydisc_rint(struct tty *tp, char c, int flags) } 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); + if (tp->t_inq.ti_end > 0) + ttydisc_reprint(tp); + tp->t_termios.c_lflag |= FLUSHO; + } } }