Patchwork [bitbake-devel] knotty: Chain the WINCH signal handler in progressbar so any other handler is preserved and called

login
register
mail settings
Submitter Richard Purdie
Date Aug. 15, 2012, 3:58 p.m.
Message ID <1345046326.14667.8.camel@ted>
Download mbox | patch
Permalink /patch/34639/
State New
Headers show

Comments

Richard Purdie - Aug. 15, 2012, 3:58 p.m.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---

Patch

diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 9f51823..34b5969 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -25,6 +25,7 @@  import sys
 import xmlrpclib
 import logging
 import progressbar
+import signal
 import bb.msg
 from bb.ui import uihelper
 
@@ -37,8 +38,21 @@  class BBProgress(progressbar.ProgressBar):
         widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ',
            progressbar.ETA()]
 
+        try:
+            self._resize_default = signal.getsignal(signal.SIGWINCH)
+        except:
+            self._resize_default = None
         progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets)
 
+    def _handle_resize(self, signum, frame):
+        progressbar.ProgressBar._handle_resize(self, signum, frame)
+        if self._resize_default:
+            self._resize_default(signum, frame)
+    def finish(self):
+        progressbar.ProgressBar.finish(self)
+        if self._resize_default:
+            signal.signal(signal.SIGWINCH, self._resize_default)
+
 class NonInteractiveProgress(object):
     fobj = sys.stdout