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) signal.signal(signal.SIGWINCH, dummy)
while True: while True:
lines, cols, height, width = struct.unpack( with open('/dev/tty', 'rb') as pty:
'HHHH', lines, cols, height, width = struct.unpack(
fcntl.ioctl(sys.stdout.fileno(), 'HHHH',
termios.TIOCGWINSZ, fcntl.ioctl(pty,
struct.pack('HHHH', 0, 0, 0, 0))) termios.TIOCGWINSZ,
struct.pack('HHHH', 0, 0, 0, 0)))
if width > 0 and height > 0: if width > 0 and height > 0:
break break