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

def get_terminal_size(fd):
    """Get the (width, height) size tuple for the given pty fd."""
    sizebuf = array.array('h', [0, 0])
    fcntl.ioctl(fd, termios.TIOCGWINSZ, sizebuf, True)
    return tuple(reversed(sizebuf))