Blame man4/pts.4

Packit 7cfc04
.\" This man page was written by Jeremy Phelps <jphelps@notreached.net>.
Packit 7cfc04
.\" Notes added - aeb
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
Packit 7cfc04
.\" Redistribute and revise at will.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.TH PTS 4 2016-03-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
ptmx, pts \- pseudoterminal master and slave
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The file
Packit 7cfc04
.I /dev/ptmx
Packit 7cfc04
is a character file with major number 5 and
Packit 7cfc04
minor number 2, usually of mode 0666 and owner.group of root.root.
Packit 7cfc04
It is used to create a pseudoterminal master and slave pair.
Packit 7cfc04
.PP
Packit 7cfc04
When a process opens
Packit 7cfc04
.IR /dev/ptmx ,
Packit 7cfc04
it gets a file
Packit 7cfc04
descriptor for a pseudoterminal master (PTM),
Packit 7cfc04
and a pseudoterminal slave (PTS) device is created in the
Packit 7cfc04
.I /dev/pts
Packit 7cfc04
directory.
Packit 7cfc04
Each file descriptor obtained by opening
Packit 7cfc04
.IR /dev/ptmx
Packit 7cfc04
is an independent PTM with its own associated PTS, whose path can
Packit 7cfc04
be found by passing the file descriptor to
Packit 7cfc04
.BR ptsname (3).
Packit 7cfc04
.PP
Packit 7cfc04
Before opening the pseudoterminal slave, you must pass the master's file
Packit 7cfc04
descriptor to
Packit 7cfc04
.BR grantpt (3)
Packit 7cfc04
and
Packit 7cfc04
.BR unlockpt (3).
Packit 7cfc04
.PP
Packit 7cfc04
Once both the pseudoterminal master and slave are open, the slave provides
Packit 7cfc04
processes with an interface that is identical to that of a real terminal.
Packit 7cfc04
.PP
Packit 7cfc04
Data written to the slave is presented on the master file descriptor as input.
Packit 7cfc04
Data written to the master is presented to the slave as input.
Packit 7cfc04
.PP
Packit 7cfc04
In practice, pseudoterminals are used for implementing terminal emulators
Packit 7cfc04
such as
Packit 7cfc04
.BR xterm (1),
Packit 7cfc04
in which data read from the pseudoterminal master is interpreted by the
Packit 7cfc04
application in the same way
Packit 7cfc04
a real terminal would interpret the data, and for implementing remote-login
Packit 7cfc04
programs such as
Packit 7cfc04
.BR sshd (8),
Packit 7cfc04
in which data read from the pseudoterminal master is sent across the network
Packit 7cfc04
to a client program that is connected to a terminal or terminal emulator.
Packit 7cfc04
.PP
Packit 7cfc04
Pseudoterminals can also be used to send input to programs that normally
Packit 7cfc04
refuse to read input from pipes (such as
Packit 7cfc04
.BR su (1),
Packit 7cfc04
and
Packit 7cfc04
.BR passwd (1)).
Packit 7cfc04
.SH FILES
Packit 7cfc04
.IR /dev/ptmx ,
Packit 7cfc04
.I /dev/pts/*
Packit 7cfc04
.SH NOTES
Packit 7cfc04
The Linux support for the above (known as UNIX 98 pseudoterminal naming)
Packit 7cfc04
is done using the
Packit 7cfc04
.I devpts
Packit 7cfc04
filesystem, that should be mounted on
Packit 7cfc04
.IR /dev/pts .
Packit 7cfc04
.PP
Packit 7cfc04
Before this UNIX 98 scheme, master pseudoterminals were called
Packit 7cfc04
.IR /dev/ptyp0 ", ..."
Packit 7cfc04
and slave pseudoterminals
Packit 7cfc04
.IR /dev/ttyp0 ", ..."
Packit 7cfc04
and one needed lots of preallocated device nodes.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR getpt (3),
Packit 7cfc04
.BR grantpt (3),
Packit 7cfc04
.BR ptsname (3),
Packit 7cfc04
.BR unlockpt (3),
Packit 7cfc04
.BR pty (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.