ptybandage
1
user commands
djbwares
ptybandage
wrap a transparent pty around a program
ptybandage
subprogram
args
Description
ptybandage obtains a new pty and runs subprogram under it.
This has the following effects:
Descriptors 0, 1, and 2 of subprogram are redirected to the pty.
ptybandage's input is transparently forwarded to the pty's input; the pty's output is transparently forwarded to ptybandage's output.
The pty's mode is set to the mode of ptybandage's controlling tty.
Meanwhile, ptybandage's controlling tty is set to raw mode.
When subprogram exits, ptybandage exits with the same exit code, after restoring the mode of its controlling tty.
If subprogram stops, ptybandage stops with the same signal, temporarily restoring the mode of its controlling tty.
When ptybandage continues, subprogram's process group will receive a SIGCONT.
ptybandage forwards window-size changes to the pty.
The controlling tty of subprogram is replaced with the pty.
As an added bonus, ptybandage gives subprogram descriptor 3 pointing to /dev/tty, and an environment variable TTY giving the name of the pty.
Beware: ptybandage also closes descriptors 4, 5, and 9.
ptybandage is useful for handling programs that refuse to run inside a pipe.
As far as subprogram can see, it is talking to a tty.
ptybandage doesn't mind being put inside a pipe.
ptybandage also fools isatty3.
If subprogram uses stdio, its output will be line-buffered.
ptybandage is a synonym for ptyget ptyio -t ptyspawn.
ptyspawn1 options may be used with ptybandage.
History
ptybandage 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.