diff --git a/src/calibre/utils/terminal.py b/src/calibre/utils/terminal.py index 8f899396d8..0632803e18 100644 --- a/src/calibre/utils/terminal.py +++ b/src/calibre/utils/terminal.py @@ -330,7 +330,7 @@ def get_term_geometry(): def ioctl_GWINSZ(fd): try: - return struct.unpack(b'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, b'1234')) + return struct.unpack(b'HHHH', fcntl.ioctl(fd, termios.TIOCGWINSZ, b'\0'*8))[:2] except Exception: return None, None