ptyspawn — run a program under a pty
ptyspawn [-2] [-3] [-x] {subprogram} {args...}
ptyspawn runs subprogram under a pty.
ptyspawn will exit when subprogram exits, with the same exit code.
ptyspawn must be invoked with descriptor 4 pointing to the pty master, descriptor 5 pointing to the pty slave, and environment variable TTY giving the name of the pty slave.
On POSIX systems, ptyspawn must not be a process group leader.
If subprogram stops, ptyspawn writes its stop signal, as a single byte, to descriptor 9, if descriptor 9 is open.
When ptyspawn receives a SIGCONT signal, it sends SIGCONT to subprogram's process group.
subprogram will have descriptors 0, 1, and 2 pointing to the pty slave.
Its controlling tty will be that pty.
Descriptor 3 will point to /dev/tty.
Descriptors 4, 5, and 9 will be closed.
subprogram will be a process group leader.