Set default terminal size (80x24) for non-interactive mode

This commit is contained in:
Jakub Jedelsky
2014-01-27 10:40:36 +01:00
committed by jakubjedelsky
parent 766518e51e
commit fd278533bd

View File

@@ -26,9 +26,13 @@ class PtyRecorder(object):
''' '''
# Get the terminal size of the real terminal, set it on the pseudoterminal. # Get the terminal size of the real terminal, set it on the pseudoterminal.
buf = array.array('h', [0, 0, 0, 0]) if os.isatty(pty.STDOUT_FILENO):
fcntl.ioctl(pty.STDOUT_FILENO, termios.TIOCGWINSZ, buf, True) buf = array.array('h', [0, 0, 0, 0])
fcntl.ioctl(master_fd, termios.TIOCSWINSZ, buf) fcntl.ioctl(pty.STDOUT_FILENO, termios.TIOCGWINSZ, buf, True)
fcntl.ioctl(master_fd, termios.TIOCSWINSZ, buf)
else:
buf = array.array('h', [24, 80, 0, 0])
fcntl.ioctl(master_fd, termios.TIOCSWINSZ, buf)
def _signal_winch(signal, frame): def _signal_winch(signal, frame):
'''Signal handler for SIGWINCH - window size has changed.''' '''Signal handler for SIGWINCH - window size has changed.'''