From 74671532a7af18244ce7abe1bd8c6c88fb5a342b Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 3 Jan 2022 11:46:59 +0100 Subject: [PATCH] Fix crash on terminal resize during download --- osc/meter.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osc/meter.py b/osc/meter.py index 3372a1a1..129147ff 100644 --- a/osc/meter.py +++ b/osc/meter.py @@ -3,6 +3,9 @@ # and distributed under the terms of the GNU General Public Licence, # either version 2, or (at your option) any later version. + +import signal + try: import progressbar as pb have_pb_module = True @@ -23,6 +26,11 @@ class PBTextMeter(object): # a ZeroDivisionException widgets.insert(1, pb.Percentage()) self.bar = pb.ProgressBar(widgets=widgets, maxval=size) + # When a signal handler is set, it resets SA_RESTART flag + # - see signal.siginterrupt() python docs. + # ProgressBar's constructor sets signal handler for SIGWINCH. + # So let's make sure that it doesn't interrupt syscalls in osc. + signal.siginterrupt(signal.SIGWINCH, False) self.bar.start() def update(self, amount_read):