unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Helmut Eller <eller.helmut@gmail.com>
To: 24608@debbugs.gnu.org
Subject: bug#24608: 26.0.50; PTY window size initially zero
Date: Tue, 04 Oct 2016 10:18:05 +0200	[thread overview]
Message-ID: <m2pongsf2a.fsf@gmail.com> (raw)

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





             reply	other threads:[~2016-10-04  8:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04  8:18 Helmut Eller [this message]
2020-11-30 12:14 ` bug#24608: 26.0.50; PTY window size initially zero 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=m2pongsf2a.fsf@gmail.com \
    --to=eller.helmut@gmail.com \
    --cc=24608@debbugs.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).