Subject: Re: bug#10959: 23.3; emacs -nw doesn't always restore the terminal screen

From: Eli Zaretskii <[email-masked]>
Date: Sat, 16 Jun 2012 10:41:26 +0300

> From: Stefan Monnier <[email-masked]>
> Date: Sat, 16 Jun 2012 02:26:41 -0400
> Cc: [email-masked]
> 
> >> This problem still occurs with GNU Emacs 23.4.1 from the Debian
> >> package emacs23 23.4+1-2 (tested in xterm).
> > and it still occurs with the official GNU Emacs 24.1.1.
> 
> Thanks for checking and confirming.  I hope someone who actually know
> about such terminal setup/restore will have a chance to look at it.

I know very little about this, but here's what I know: this feature
relies upon the "ti" and "te" terminal capabilities.  We use these
capabilities in tty_set_terminal_modes and tty_reset_terminal_modes,
respectively.  In both cases, we output the terminal command only if
the tty->output FILE stream is non-NULL.  So perhaps some timing
issues cause tty->output to become NULL before we get to
tty_reset_terminal_modes, or maybe it is still NULL when we get to
tty_set_terminal_modes?  In any case, adding some logs to those places
could show if that is the problem.

Alternatively, could it be a problem with the terminal emulators, not
in Emacs?