|
ginnOS
The reference: libc, the libraries and the kernel
|
open a pseudo-terminal pair, and make one a process's terminal. More...
Go to the source code of this file.
Functions | |
| int | openpty (int *master, int *slave, char *name, const struct termios *settings, const struct winsize *size) |
| open a new pseudo-terminal pair. | |
| int | login_tty (int fd) |
| make fd the terminal of the calling process: start a new session, make fd its controlling terminal, put fd on stdin, stdout and stderr, and close fd. | |
open a pseudo-terminal pair, and make one a process's terminal.
pseudo-terminals: /dev/ptmx and /dev/pts/N.
a terminal app (mimir) opens /dev/ptmx and gets the master side of a new pair. the program it runs (a shell) uses the slave side, /dev/pts/N, as its terminal: the same termios settings, job control ioctls and window size as the console. bytes the master writes go through the slave's line discipline (line editing, echo, the signal keys) and are read by the slave; bytes the slave writes are read by the master.
the user interface is the Linux one: TIOCGPTN gives N, TIOCSPTLCK with 0 unlocks the slave (unlockpt), TIOCSWINSZ sets the size and sends SIGWINCH to the foreground process group.
limits: VTIME is not used (a read with VMIN 0 does not wait at all). the master's writes wait when the slave does not read; a terminal app that also reads the master in the same thread uses O_NONBLOCK and poll.
| int openpty | ( | int * | master, |
| int * | slave, | ||
| char * | name, | ||
| const struct termios * | settings, | ||
| const struct winsize * | size ) |
open a new pseudo-terminal pair.
| master | receives the master fd. |
| slave | receives the slave fd. |
| name | receives the slave's path, if not NULL (at least 16 bytes). |
| settings | the slave's termios, if not NULL. |
| size | the window size, if not NULL. |
| int login_tty | ( | int | fd | ) |
make fd the terminal of the calling process: start a new session, make fd its controlling terminal, put fd on stdin, stdout and stderr, and close fd.
for the child of a terminal app, before execve.