progressbar.py: Ignore 'inappropriate ioctl for device' exceptions when resizing window.

This commit is contained in:
Sebastian Lackner 2015-04-02 23:56:15 +02:00
parent 4e8ec61e11
commit 363bf09254

View File

@ -29,9 +29,14 @@ import termios
def _sig_winch(signum=None, frame=None):
"""Signal handler for SIGWINCH."""
global _term_width
h, w, hp, wp = struct.unpack('HHHH', fcntl.ioctl(sys.stdout.fileno(),
termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)))
_term_width = w
try:
h, w, hp, wp = struct.unpack('HHHH', fcntl.ioctl(sys.stdout.fileno(),
termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)))
_term_width = w
except IOError:
# ignore 'IOError: [Errno 25] Inappropriate ioctl for device',
# which can occur when resizing the window while the output is redirected
pass
try:
_sig_winch()