unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthew Leach <matthew@mattleach.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 37564@debbugs.gnu.org
Subject: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications
Date: Tue, 01 Oct 2019 19:33:39 +0100	[thread overview]
Message-ID: <87sgocfh8c.fsf@mattleach.net> (raw)
In-Reply-To: <83a7aka1q5.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 01 Oct 2019 19:07:30 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Matthew Leach <matthew@mattleach.net>
>> Cc: 37564@debbugs.gnu.org
>> Date: Tue, 01 Oct 2019 16:47:35 +0100
>> 
>> > Thanks, but I don't think we can make this change unconditionally,
>> > because not all applications that heed LINES and COLUMNS use ncurses.
>> 
>> I'm curious as to which programs you are referring? AFAIK, if a program
>> tries to read the LINES and COLUMNS environment variables, using
>> `getenv()', they don't exist.
>
> What makes you say that? 

If I run the C program in my previous post in an xterm and resize I get:

getenv: (null) (null)
ioctl:  24 80
getenv: (null) (null)
ioctl:  42 169

You can see that doing getenv() on LINES and COLUMNS returns a null
pointer.  I've tested this same behaviour on gnome-terminal and numerous
other terminal emulators.

> Emacs exports these variables into the environment that is passed to
> child subprocesses, so those subprocesses will definitely see them
> using getenv.

I'm no expert on how these things work but it doesn't appear to be the
way that it's done, on my machine anyway.  Perhaps there are programs
that uses these variables on MacOS or Windows?

>> Nevertheless, if a program does read the LINES and COLUMNS variables,
>> these values will be wrong if the window has been resized (try and
>> compile the attached C snippet and run in term mode while resizing the
>> window). Should that be considered as a separate bug?
>
> We nowadays have window-adjust-process-window-size-function to support
> that, and term.el is using that.  So why isn't it working for you?
> Maybe you are running a version of Emacs that's too old (AFAICT, you
> didn't say which one)?

I'm testing this on the latest Emacs Git version. I can see that
window-adjust-process-window-size-function is used in term.el however,
this doesn't appear to update the environment variables exported to the
terminal process. If I run the same program with term on Emacs git and
resize I get:

getenv: 31 80
ioctl:  30 89
getenv: 31 80
ioctl:  30 90
getenv: 31 80
ioctl:  30 91
getenv: 31 80
ioctl:  31 92
getenv: 31 80
ioctl:  31 93
getenv: 31 80
ioctl:  31 94
...

Notice that the values returned by getenv don't change.

Given that this functionality is broken, I'm suggesting that we don't
export the variables. This will make ncurses fall back to using ioctls
for window size inspection. Another way to fix this would be to somehow
update the environment variables that are exported to the process. What
are your thoughts?

Thanks,
-- 
Matt





  reply	other threads:[~2019-10-01 18:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 19:59 bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications Matthew Leach
2019-10-01  6:01 ` Eli Zaretskii
2019-10-01 15:47   ` Matthew Leach
2019-10-01 16:07     ` Eli Zaretskii
2019-10-01 18:33       ` Matthew Leach [this message]
2019-10-01 18:58         ` Eli Zaretskii
2019-10-01 19:14           ` Eli Zaretskii
2019-10-01 19:24           ` Matthew Leach
2019-10-02  2:28             ` Eli Zaretskii
2019-10-03 17:51               ` Glenn Morris
2019-10-04 18:48                 ` Matthew Leach
2020-01-20 19:10                   ` Stefan Kangas
2020-01-20 19:30                     ` Eli Zaretskii
2020-01-21  0:58                       ` Glenn Morris
2020-01-21 17:11                         ` Eli Zaretskii
2020-01-21 18:10                           ` Matthew Leach
2020-01-22  3:38                         ` Glenn Morris
2020-01-22 15:46                           ` Eli Zaretskii
2020-06-04 16:01                             ` Glenn Morris
2020-08-15 12:37                             ` Lars Ingebrigtsen
2020-01-24 18:08                           ` Stefan Kangas
2020-01-21  3:04                       ` Stefan Kangas
2019-10-04 18:47               ` Matthew Leach
2019-10-07  4:11             ` Lars Ingebrigtsen
2019-10-07  9:16               ` Andreas Schwab
2019-10-08 16:38                 ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgocfh8c.fsf@mattleach.net \
    --to=matthew@mattleach.net \
    --cc=37564@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).