ptyget 8 user commands djbwares
ptyget allocate a pty
`ptyget` subprogram args

## Description

`ptyget` allocates a new pty, makes the master side available as fd 4 (non-blocking), makes the slave side available as fd 5, and runs subprogram. It passes subprogram a `TTY` environment variable giving the name of the pty slave.

On current systems, `ptyget` is setuid `root` and setgid `tty`. It changes the ownership of the pty slave to the user, so that the user can open it, and makes it mode `600`, so that nobody else can open it. It also puts the pty slave under group `tty`. It will refuse to run if these protections fail.

`ptyget` does not make any provisions to clean up when the user finishes using the pty.

## System-specific notes

On systems with the POSIX 2001 compliant posix_openpt 3, ptsname 3, grantpt 3, and unlockpt 3, functions, `ptyget` doesn't know nor care where the master or slave actually are. It uses the library functions to do most of the work.

On other pty/tty-based systems (e.g., BSD 4.4), the slave is `/dev/ttyxy` where xy are two characters. `ptyget` searches through masters starting from a random point (with a random increment to avoid secondary clustering). `ptyget` relies for security on the kernel's revoke 3 function.

On other ptmx/pts-based systems (e.g., Solaris), the slave is `/dev/pts/N` where N is a nonnegative integer. `ptyget` does not invoke `/usr/lib/pt_chmod`. `ptyget` relies for security on the kernel's built-in slave locking.

## History

`ptyget` 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.