generate-alt-random: do ioctl(TIOCGWINSZ) on /dev/tty, not stdout

This commit is contained in:
Daniel Eklöf 2021-04-22 11:00:31 +02:00
parent 44b8bd2364
commit 10e512f14f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -45,11 +45,12 @@ def main():
signal.signal(signal.SIGWINCH, dummy)
while True:
lines, cols, height, width = struct.unpack(
'HHHH',
fcntl.ioctl(sys.stdout.fileno(),
termios.TIOCGWINSZ,
struct.pack('HHHH', 0, 0, 0, 0)))
with open('/dev/tty', 'rb') as pty:
lines, cols, height, width = struct.unpack(
'HHHH',
fcntl.ioctl(pty,
termios.TIOCGWINSZ,
struct.pack('HHHH', 0, 0, 0, 0)))
if width > 0 and height > 0:
break