Fork a new process with a new pseudo-terminal as controlling tty.
Returns a tuple of (pid, master_fd).
Like fork(), return pid of 0 to the child process,
and pid of child to the parent process.
To both, return fd of newly opened pseudo-terminal.
The master_fd is non-inheritable.
3.8: Calling forkpty() in a subinterpreter is no longer supported (RuntimeError is raised).
3.12: If Python is able to detect that your process has multiple threads, this now raises a DeprecationWarning. See the longer explanation on os.fork().
3.15: The returned file descriptor is now made non-inheritable.