Subject: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications

From: Eli Zaretskii <[email-masked]>
Date: Wed, 02 Oct 2019 05:28:15 +0300

> From: Matthew Leach <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 01 Oct 2019 20:24:14 +0100
> 
> > I simply tried "env | fgrep LINES" and I do see the variable, although
> > it wasn't there before I launched Emacs.
> 
> I would expect the variable to be there when inside Emacs as it has
> exported it.  You should find that it won't exist if ran outside Emacs,
> for example in xterm.

Sorry, I'm confused.  Are we talking about running "M-x term" inside
Emacs, or are we talking about something else?  The subject of the bug
report says "term", so I assumed you mean term-mode.

> Ah, indeed if I try and resize and print the variable it has updated:
> 
> matthew@hopton ~ $ env | grep -i lines
> LINES=30
> matthew@hopton ~ $ env | grep -i lines
> LINES=12
> 
> I think the issue is that the environment can't be while a process is
> running; the environment variables are fixed when the program has
> started. For a ncurses application this presents a problem as LINES and
> COLUMNS can't be updated when the window size is changed and the program
> handles a SIGWINCH. You can see that on the output above.

While the process is running, Emacs sends ioctl commands to
communicate the window size changes.