unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24608: 26.0.50; PTY window size initially zero
@ 2016-10-04  8:18 Helmut Eller
  2020-11-30 12:14 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Helmut Eller @ 2016-10-04  8:18 UTC (permalink / raw)
  To: 24608

When a subprocess tries to read the window size of the tty with the
TIOCGWINSZ ioctl the result is initially zero.  This causes problems for
programs that aren't prepared for zero sized windows.  It would be
better if the size would be initialized correctly or at least not be
zero.

To reproduce the situation compile the attached C program and execute
Emacs like this:
 emacs -Q -nw -f shell \
   --eval '(progn (sit-for 1) (insert "getwinsize") (comint-send-input))' \
   --eval '(progn (sit-for 1) (insert "getwinsize") (comint-send-input))' \
   --eval '(progn (sit-for 1) (delete-other-windows) (insert "getwinsize") (comint-send-input))'

After that, the *shell* buffer look like so:

  helmut@caladan:/tmp> getwinsize
  Window size: 0 columns 0 rows
  helmut@caladan:/tmp> getwinsize
  Window size: 0 columns 0 rows
  helmut@caladan:/tmp> getwinsize
  Window size: 80 columns 21 rows
  helmut@caladan:/tmp> 

We see that the size is initially zero but after resizing the window the
size is no longer zero.  (Note: when typing the commands manually
tab-completion may create temporary windows and will initialize the
window size as side effect.)

Here the C programm to read the window size:

/* -*- compile-command:"cc getwinsize.c -o getwinsize" -*- */
#include <sys/ioctl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
  struct winsize sz;
  if (ioctl (0, TIOCGWINSZ, &sz) == -1)
    {
      printf ("ioctl failed: %s", strerror (errno));
      exit (1);
    }
  printf ("Window size: %i columns %i rows\n", sz.ws_col, sz.ws_row);
  return 0;
}


In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.5)
 of 2016-10-04 built on caladan
Repository revision: e2913dc880b9843bf69cf885270551bafeb46120
Windowing system distributor 'The X.Org Foundation', version 11.0.11604000
System Description:	Debian GNU/Linux 8.5 (jessie)

Configured using:
 'configure --with-xpm=no --with-jpeg=no --with-gif=no --with-tiff=no'

Configured features:
PNG SOUND DBUS GSETTINGS NOTIFY GNUTLS LIBXML2 FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#24608: 26.0.50; PTY window size initially zero
  2016-10-04  8:18 bug#24608: 26.0.50; PTY window size initially zero Helmut Eller
@ 2020-11-30 12:14 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-11-30 12:14 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 24608

Helmut Eller <eller.helmut@gmail.com> writes:

> When a subprocess tries to read the window size of the tty with the
> TIOCGWINSZ ioctl the result is initially zero.  This causes problems for
> programs that aren't prepared for zero sized windows.  It would be
> better if the size would be initialized correctly or at least not be
> zero.
>
> To reproduce the situation compile the attached C program and execute
> Emacs like this:
>  emacs -Q -nw -f shell \
>    --eval '(progn (sit-for 1) (insert "getwinsize") (comint-send-input))' \
>    --eval '(progn (sit-for 1) (insert "getwinsize") (comint-send-input))' \
>    --eval '(progn (sit-for 1) (delete-other-windows) (insert "getwinsize") (comint-send-input))'
>
> After that, the *shell* buffer look like so:
>
>   helmut@caladan:/tmp> getwinsize
>   Window size: 0 columns 0 rows
>   helmut@caladan:/tmp> getwinsize
>   Window size: 0 columns 0 rows
>   helmut@caladan:/tmp> getwinsize
>   Window size: 80 columns 21 rows
>   helmut@caladan:/tmp> 

(This bug report unfortunately got no response at the time.)

I'm not getting exactly this (in Emacs 27):

arsi@xo:~/src/emacs/trunk$ /tmp/getwinsize
/tmp/getwinsize
/tmp/getwinsize
larsi@xo:~/src/emacs/trunk$ larsi@xo:~/src/emacs/trunk$ Window size: 0 columns \
0 rows
larsi@xo:~/src/emacs/trunk$ Window size: 0 columns 0 rows
larsi@xo:~/src/emacs/trunk$ Window size: 0 columns 0 rows

But it's still wrong.  However, in Emacs 28, I'm getting:

/tmp/getwinsize
/tmp/getwinsize
/tmp/getwinsize
larsi@xo:~/src/emacs/trunk$ larsi@xo:~/src/emacs/trunk$ larsi@xo:~/src/emacs/tr\
unk$ Window size: 79 columns 21 rows
larsi@xo:~/src/emacs/trunk$ Window size: 79 columns 21 rows
larsi@xo:~/src/emacs/trunk$ Window size: 79 columns 21 rows

So I'm going to go ahead and guess that this has been fixed now, and I'm
closing this bug report.  If this is still an issue, please respond to
the debbugs address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-30 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-04  8:18 bug#24608: 26.0.50; PTY window size initially zero Helmut Eller
2020-11-30 12:14 ` Lars Ingebrigtsen

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).