Control: retitle -1 term should clear discard-output flag in more situations
Although the FreeBSD manual page for termios(4) https://www.freebsd.org/cgi/man.cgi?query=termios&apropos=0&sektion=4&manpath=FreeBSD+10.3-RELEASE+and+Ports&arch=default&format=html documents the DISCARD key, the kernel doesn't appear to implement it: https://svnweb.freebsd.org/base/stable/10/sys/kern/tty_ttydisc.c?revision=256281&view=markup#l897 There, the ttydisc_rint function recognizes VLNEXT but not VDISCARD. In contrast, NetBSD implements DISCARD: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/tty.c?rev=1.271&content-type=text/x-cvsweb-markup&only_with_tag=MAIN There, the ttyinput_wlock function recognizes VDISCARD and toggles the FLUSHO flag. This flag is also cleared in several more places: * At the end of ttyinput_wlock, except in these cases: - a break, parity error, or a framing error was ignored - the DISCARD or STOP character was just received - output remains suspended with STOP. * In the ttioctl function, if the TIOCSTART ioctl is used. * In the ttioctl function, if the TIOCSETA, TIOCSETAW, or TIOCSETAF ioctl is used. It actually copies the flag from the FLUSHO bit of termios::c_lflag. * In the ttyrub function, if the ECHO flag is set and the EXTPROC flag is not set. This function is called when a previously typed character needs to be deleted. * In the ttyecho function, unless it's being called because the user pressed the TAB key. The term translator should thus be changed: * Clear the discard-output flag when the user types almost any other character, like the glibc documentation said. * Clear the discard-output flag when TIOCSTART is used. This is term/users.c (S_tioctl_tiocstart), I believe. * Copy the discard-output flag from the FLUSHO bit of termios::c_lflag, when TIOCSETA, TIOCSETAW, or TIOCSETAF is used. This is term/users.c (set_state), I believe. The GNU C Library already defines FLUSHO in both <bits/ioctls.h> and <bits/termios.h>. With those changes, I think my previous open_hook patch would no longer be necessary because sshd would call tcsetattr without FLUSHO and thereby clear the flag.