code: def setwinsize(fd, rows_cols):
      
      rows, cols = rows_cols
      TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561)
  
      s = struct.pack('HHHH', rows, cols, 0, 0)
      fcntl.ioctl(fd, TIOCSWINSZ, s)
docs: set the terminal size of a tty file descriptor.  borrowed logic
      from pexpect.py