ptyspawn
8
user commands
djbwares
ptyspawn
run a program under a pty
ptyspawn
-2
-3
-x
subprogram
args
Description
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.
Options
-2
Preserve descriptor 2 in subprogram; do not replace it with the pty slave.
-3
Preserve descriptor 3 in subprogram; do not replace it with /dev/tty.
-x
Reserve the pty for exclusive use.
This prevents all attempts to open the pty, even through /dev/tty.
History
ptyspawn was originally part of Daniel J. Bernstein's ptyget toolset in 1996.
Author
Original code and documentation by Daniel J. Bernstein.
Documentation modernizations by Jonathan de Boyne Pollard.