Control: retitle -1 hurd: should clear discard-output flag when pseudoterminal is destroyed
Samuel Thibault noted that pressing ^O a second time makes the terminal work again. It turns out this is a documented feature. https://www.gnu.org/software/libc/manual/html_node/Other-Special.html#index-VDISCARD says: > The DISCARD character is recognized only when IEXTEN is set, > but in both canonical and noncanonical mode. Its effect is to > toggle the discard-output flag. When this flag is set, all > program output is discarded. Setting the flag also discards all > output currently in the output buffer. Typing any other > character resets the flag. > > This character is available on BSD systems and GNU/Linux and > GNU/Hurd systems. Contrary to this glibc documentation, typing another character does not reset the flag on GNU/Hurd. I don't know whether that is a bug in Hurd. IEEE Std 1003.1, 2013 Edition reserves the VDISCARD name but does not say how it works. http://www.unix.com/man-page/freebsd/4/termios/ describes the DISCARD character but does not say that other characters reset the flag. Linux 3.16.0 has room for the DISCARD character in struct termios but does not recognize it when typed, even if IEXTEN is set. This explains why I was not familiar with the feature. That leaves one problem: if I first set the discard-output flag by pressing ^O, and then kill the ssh client so that the processes using the pseudoterminal get SIGHUP and die, the flag remains set. If someone else then logs in via ssh and happens to get the same tty/pty pair, they get neither /etc/motd nor the shell prompt. They can fix the situation by pressing ^O but surely the discard-output should be cleared automatically. In the hurd/term code, the flag is termflags & FLUSH_OUTPUT. The flag is changed only in main.c (main), which initializes the whole termflags variable, and in munge.c (input_character), which toggles the flag if it gets the DISCARD character. There is no ioctl that explicitly reports or changes the state of the flag. It is thus not feasible for sshd to clear the flag; instead, the term translator should do that on its own. Samuel Thibault suggests that the flag should be cleared in ptyio.c (pty_po_destroy_hook) or users.c (po_destroy_hook). I think pseudoterminals should entirely reinitialize termflags and other terminal-specific state between sessions because that's what would happen with /dev/pts/ (Debian bug#556550) too. With other kinds of terminals ("device" or "hurdio"), one can expect that the same device will remain connected, so it seems better to preserve the terminal settings.