Package: reportbug
Version: 6.6.6
Severity: normal
Tags: patch

Dear Maintainer,

   * What led up to the situation?

I ran 'querybts' in an xterm and resized the xterm while querybts was running.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

1. Resize the terminal to 80x25.
2. Run 'querybts 808808'.
3. Maximize the terminal window.  [This can be done during or after the
   next step, too, but must be done after typing <Enter> at the end of
   the previous step.]
4. Type <q><e><Enter> to close 'less' and open 'mutt'.

   * What was the outcome of this action?

Mutt only used the top-left 80x25 cells of the terminal.

   * What outcome did you expect instead?

Mutt using the full size of the maximized terminal.

   *

The root of the problem is that the $LINES and $COLUMNS environment variables
have outdated values after the resize.  Having a SIGWINCH handler that either
unsets those two variables or updates their values fixes the issue.  Patches
to do both are attached.

(The patches are mutually exclusive.)

Cheers,

Daniel

P.S. Full disclosure: The code in the putenv() patch is based on Apache
Licensed code from [1].  I assume that is okay.
[1] 
https://svn.apache.org/viewvc/subversion/trunk/build/run_tests.py?revision=1717356&view=markup#l81


-- Package-specific info:
** Environment settings:
DEBEMAIL="Daniel Shahaf <danie...@apache.org>"
DEBFULLNAME="Daniel Shahaf"
INTERFACE="text"

** /home/daniel/.reportbugrc:
reportbug_version "6.6.3"
mode standard
ui text
realname "Daniel Shahaf"
email "danie...@apache.org"
no-cc
header "X-Debbugs-CC: danie...@apache.org"
smtphost reportbug.debian.org
mbox_reader_cmd "mutt -f %s"

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.3.0-1-amd64 (SMP w/1 CPU core)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages reportbug depends on:
ii  apt               1.1.10
ii  python-reportbug  6.6.6
pn  python:any        <none>

reportbug recommends no packages.

Versions of packages reportbug suggests:
pn  claws-mail                                 <none>
pn  debconf-utils                              <none>
pn  debsums                                    <none>
pn  dlocate                                    <none>
pn  emacs23-bin-common | emacs24-bin-common    <none>
ii  exim4                                      4.86-7
ii  exim4-daemon-light [mail-transport-agent]  4.86-7+b1
ii  file                                       1:5.25-2
ii  gnupg                                      1.4.20-1
pn  python-gtk2                                <none>
pn  python-gtkspellcheck                       <none>
pn  python-urwid                               <none>
pn  python-vte                                 <none>
pn  xdg-utils                                  <none>

Versions of packages python-reportbug depends on:
ii  apt               1.1.10
ii  file              1:5.25-2
ii  python-debian     0.1.27
ii  python-debianbts  2.6.0
pn  python:any        <none>

python-reportbug suggests no packages.

-- no debconf information
diff --git a/bin/querybts b/bin/querybts
index 17d5328..b3cb9dc 100755
--- a/bin/querybts
+++ b/bin/querybts
@@ -21,6 +21,7 @@
 #  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 #  SOFTWARE.
 
+import signal
 import sys
 import os
 import optparse
@@ -46,6 +47,24 @@ VERSION = "querybts %s" % VERSION_NUMBER
 
 
 def main():
+    # Set up signal handlers
+    import fcntl, termios, struct
+    def handler(signum, frame):
+        if signum == signal.SIGWINCH:
+            # The terminal has been resized.  Update $LINES and $COLUMNS,
+            # since some programs (including Mutt) use those in preference
+            # to TIOCGWINSZ for determining their terminal size, and would
+            # look garbled without this.
+            fd = os.open(os.ctermid(), os.O_RDONLY)
+            lines, columns = struct.unpack('hh',
+                                           fcntl.ioctl(fd, termios.TIOCGWINSZ,
+                                                       struct.pack('hh', 0, 0)))
+            os.close(fd)
+            os.putenv('COLUMNS', str(columns))
+            os.putenv('LINES', str(lines))
+        pass
+    signal.signal(signal.SIGWINCH, handler)
+
     # default values for cli options
     defaults = dict(system='debian', archived=False,
                     http_proxy='', interface='text',
diff --git a/bin/querybts b/bin/querybts
index 17d5328..154bc5d 100755
--- a/bin/querybts
+++ b/bin/querybts
@@ -21,6 +21,7 @@
 #  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 #  SOFTWARE.
 
+import signal
 import sys
 import os
 import optparse
@@ -46,6 +47,20 @@ VERSION = "querybts %s" % VERSION_NUMBER
 
 
 def main():
+    # Set up signal handlers
+    def handler(signum, frame):
+        if signum == signal.SIGWINCH:
+            # The terminal has been resized.
+            #
+            # Removing the now-stale values of $LINES and $COLUMNS prevents
+            # Mutt from looking garbled.  Mutt appears to use $LINES and
+            # $COLUMNS in preference to TIOCGWINSZ for determining its
+            # terminal size.
+            os.unsetenv('LINES')
+            os.unsetenv('COLUMNS')
+        pass
+    signal.signal(signal.SIGWINCH, handler)
+
     # default values for cli options
     defaults = dict(system='debian', archived=False,
                     http_proxy='', interface='text',
_______________________________________________
Reportbug-maint mailing list
Reportbug-maint@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reportbug-maint

Reply via email to