os.openpty()

os.openpty() -> (master_fd, slave_fd)

Open a pseudo-terminal, returning open fd’s for both master and slave end.