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

From: Vincent Lefevre <[email-masked]>
Date: Sat, 16 Jun 2012 18:13:26 +0200

On 2012-06-16 10:41:26 +0300, Eli Zaretskii wrote:
> 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?

Since the bug is not always reproducible, it is likely to be a timing
problem.

> In any case, adding some logs to those places could show if that is
> the problem.

Yes, this would be a good idea.

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

As this problem occurs with 3 different terminal emulators (including
at least 2 very different ones: xterm and gnome-terminal), I doubt
about this.

On 2012-06-16 18:00:31 +0800, Chong Yidong wrote:
> I committed a patch to xterm.el that seems to stop the bug from
> happening with the posted recipe.  It adds a `discard-input' call before
> doing the xterm Report Background query, as is already done for the
> Device Attributes query earlier in `terminal-init-xterm'.  I am still
> not 100% sure of the chain of effect leading to the bug, though.

I wonder whether this makes the timing problem much less likely
or this is a real fix (there isn't any input from the user). Is
xterm.el also used for gnome-terminal?

Is this related to the following bug?

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11129

-- 
Vincent Lefèvre <[email-masked]> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)