From owner-freebsd-stable@FreeBSD.ORG Sat Jul 5 11:10:16 2014 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D7F13842 for ; Sat, 5 Jul 2014 11:10:16 +0000 (UTC) Received: from nmsh4.e.nsc.no (nmsh4.e.nsc.no [193.213.121.75]) by mx1.freebsd.org (Postfix) with ESMTP id 426782DF3 for ; Sat, 5 Jul 2014 11:10:15 +0000 (UTC) Received: from terraplane.org (ti0027a400-1392.bb.online.no [83.109.176.119]) by nmsh4.nsc.no (8.14.7/8.14.7) with ESMTP id s65AWCi0009098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 5 Jul 2014 12:32:13 +0200 (MEST) Received: from terraplane.org (localhost [127.0.0.1]) by terraplane.org (8.14.5/8.14.5) with ESMTP id s65AYGcg059897 for ; Sat, 5 Jul 2014 12:34:16 +0200 (CEST) (envelope-from rumrunner@terraplane.org) Received: (from rumrunner@localhost) by terraplane.org (8.14.5/8.13.8/Submit) id s65AYGXv059896 for freebsd-stable@freebsd.org; Sat, 5 Jul 2014 12:34:16 +0200 (CEST) (envelope-from rumrunner) Date: Sat, 5 Jul 2014 12:34:16 +0200 From: Eivind Nicolay Evensen To: freebsd-stable@freebsd.org Subject: Re: Support DISCARD (^O) Message-ID: <20140705103415.GA55807@klump.hjerdalen.lokalnett> References: <20131217211816.GA41797@klump.hjerdalen.lokalnett> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131217211816.GA41797@klump.hjerdalen.lokalnett> X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jul 2014 11:10:16 -0000 On Tue, Dec 17, 2013 at 10:18:16PM +0100, Eivind Evensen wrote: > Hello. > > I don't know if there is any particular reason that support for DISCARD/^O > was not included in the tty rewrite that happened from FreeBSD 7 to 8, > but in case anybody else wants it, here's a diff functioning mostly > like in 7, except output isn't switched back on automatically on input. > > Diff is against FreeBSD 8, however, last time I checked I didn't see > much difference in the newer versions. Here's a diff against FreeBSD 10. It seems to work fine there too. diff -r 59ad9c4b7916 -r 6e500f4552b4 sys/kern/tty_ttydisc.c --- a/sys/kern/tty_ttydisc.c Fri Jul 04 17:27:59 2014 +0200 +++ b/sys/kern/tty_ttydisc.c Fri Jul 04 17:29:29 2014 +0200 @@ -464,6 +464,9 @@ if (tp->t_flags & TF_ZOMBIE) return (EIO); + if (tp->t_termios.c_lflag & FLUSHO) + return (0); + /* * We don't need to check whether the process is the foreground * process group or if we have a carrier. This is already done @@ -896,6 +899,14 @@ /* Special control characters that are implementation dependent. */ if (CMP_FLAG(l, IEXTEN)) { + /* Discard (^O) */ + if (CMP_CC(VDISCARD, c)) { + if (!(tp->t_termios.c_lflag & FLUSHO)) + ttyoutq_write_nofrag(&tp->t_outq, "^O", 2); + tp->t_termios.c_lflag ^= FLUSHO; + return(0); + } + /* Accept the next character as literal. */ if (CMP_CC(VLNEXT, c)) { if (CMP_FLAG(l, ECHO)) {