This is a simple tool that runs a command in a pseudo-terminal as a demonstration of how to use pseudo-terminals.
- Open a new pseudo-terminal.
- Create a new child process and move it into a new session, in which the command is executed with its stdin/out/err connected to the slave side of the pseudo-terminal.
- Turn the original terminal into the non-canonical input mode so that any input to the original terminal can be passed without delay or modification.
- Forward all input and output between the original terminal and the master side of the pseudo-terminal.
- Change the window size of the pseudo-terminal accordingly when that of the original terminal is changed.
- Receive the exit status from the child process and return it as that of the wrapper itself.
- C99 compiler
- POSIX.1-2001 C API with XSI conformance
ptwrap <command> [<argument>...]
MIT