pty-basic

Section: User Commands (1)
Index Return to Main Contents
 

NAME

pty-basic - run a program under a pseudo-terminal session  

SYNTAX

pty program [ arg ... ]  

DESCRIPTION

This man page describes the effects of pty without any options. For a general overview of pty, see the pty(1) man page. For a description of the options, see the pty-opts(1) man page.

Executing pty program has approximately the same effect as executing program (with zero or more arguments). program is run under a pseudo-terminal. This means several things:

1. Its standard input, output, and error descriptors are redirected to a pseudo-terminal device driver, with effects documented in pty(4) and tty(4). This means that program may use ioctl(), for example, to affect the pseudo-terminal. So programs such as vi, which normally cannot be run inside a pipe, will see a terminal instead. (Of course, pty may be put into a pipe.)

2. isatty() and stdio's buffering will consider those descriptors to be pointing to a terminal, with effects documented in isatty(3) and setbuf(3). This means that if program uses stdio, its output will be line-buffered.

3. Input to pty program is passed through to the pseudo-terminal input. Output and error to the pseudo-terminal are passed through to the output of pty program.

4. program has controlling terminal set to the pseudo-terminal, with effects documented in tty(4).

5. pty program must have an original controlling tty. pty considers the controlling tty to be the first of the following which responds to a TIOCGPGRP ioctl: descriptor 3, /dev/tty, descriptor 0, descriptor 1, descriptor 2. pty sets that terminal to character-at-a-time, no-echo mode, to do as little processing as possible. It sets the pseudo-terminal to the original mode. When program finishes, pty sets the original terminal back to its original mode. Any mode changes on the pseudo-terminal will be lost. The original terminal is also reset whenever program is stopped (and then set back to character-at-a-time mode when program is restarted).

6. Various signals to pty program are converted into HUPs for program. Single-process signals may fail upon pty program. Process group signals as described in tty(4) will affect it normally.

7. All normal exits (including signal exits) for program are converted into exit code 0. Other exit codes indicate various new, pty-related problems, which are also announced on the standard error of pty program.

8. All file descriptors except 0, 1, and 2 are closed. 3 is reopened as the new /dev/tty, i.e., the pseudo-terminal. All controlling terminal ioctls mentioned in tty(4) may be applied to file descriptor 3 instead.

Note that pty transmits job control transparently: if program stops with (say) a TTIN, then pty program will also stop with a TTIN. When pty program is continued, program will receive a CONT.  

VERSION

pty version 4.0, 2/9/92.  

AUTHOR

Copyright 1992, Daniel J. Bernstein.  

SEE ALSO

pty(1), pty-opts(1), sess(1), condom(1), pty(4), tty(4)


 

Index

NAME
SYNTAX
DESCRIPTION
VERSION
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 06:18:47 GMT, December 12, 2024