Set the (width, height) size tuple for the given pty fd.

def set_terminal_size(fd, size):
    """Set the (width, height) size tuple for the given pty fd."""
    sizebuf = array.array('h', reversed(size))
    fcntl.ioctl(fd, termios.TIOCSWINSZ, sizebuf)