]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/pts.4
signal.7: Minor text rework
[thirdparty/man-pages.git] / man4 / pts.4
CommitLineData
fea681da
MK
1.\" This man page was written by Jeremy Phelps <jphelps@notreached.net>.
2.\" Notes added - aeb
2297bf0e 3.\"
73624cb2 4.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
fea681da 5.\" Redistribute and revise at will.
8ff7380d 6.\" %%%LICENSE_END
fea681da 7.\"
97986708 8.TH PTS 4 2016-03-15 "Linux" "Linux Programmer's Manual"
fea681da 9.SH NAME
b218b023 10ptmx, pts \- pseudoterminal master and slave
fea681da 11.SH DESCRIPTION
509e2056
MK
12The file
13.I /dev/ptmx
14is a character file with major number 5 and
6f5b156b 15minor number 2, usually with mode 0666 and ownership root:root.
b218b023 16It is used to create a pseudoterminal master and slave pair.
fea681da 17.PP
509e2056
MK
18When a process opens
19.IR /dev/ptmx ,
20it gets a file
b218b023
MK
21descriptor for a pseudoterminal master (PTM),
22and a pseudoterminal slave (PTS) device is created in the
fea681da 23.I /dev/pts
c13182ef 24directory.
509e2056
MK
25Each file descriptor obtained by opening
26.IR /dev/ptmx
fea681da 27is an independent PTM with its own associated PTS, whose path can
d9cb0d7d 28be found by passing the file descriptor to
fea681da
MK
29.BR ptsname (3).
30.PP
b218b023 31Before opening the pseudoterminal slave, you must pass the master's file
fea681da
MK
32descriptor to
33.BR grantpt (3)
34and
35.BR unlockpt (3).
36.PP
b218b023 37Once both the pseudoterminal master and slave are open, the slave provides
fea681da
MK
38processes with an interface that is identical to that of a real terminal.
39.PP
d9cb0d7d 40Data written to the slave is presented on the master file descriptor as input.
fea681da
MK
41Data written to the master is presented to the slave as input.
42.PP
b218b023 43In practice, pseudoterminals are used for implementing terminal emulators
c13182ef 44such as
fea681da 45.BR xterm (1),
b218b023 46in which data read from the pseudoterminal master is interpreted by the
fea681da
MK
47application in the same way
48a real terminal would interpret the data, and for implementing remote-login
49programs such as
50.BR sshd (8),
b218b023 51in which data read from the pseudoterminal master is sent across the network
fea681da
MK
52to a client program that is connected to a terminal or terminal emulator.
53.PP
40a1b471 54Pseudoterminals can also be used to send input to programs that normally
fea681da 55refuse to read input from pipes (such as
49ec013c 56.BR su (1),
fea681da 57and
49ec013c 58.BR passwd (1)).
fea681da
MK
59.SH FILES
60.IR /dev/ptmx ,
61.I /dev/pts/*
62.SH NOTES
b218b023 63The Linux support for the above (known as UNIX 98 pseudoterminal naming)
fea681da
MK
64is done using the
65.I devpts
9ee4a2b6 66filesystem, that should be mounted on
fea681da 67.IR /dev/pts .
dd3568a1 68.PP
b218b023 69Before this UNIX 98 scheme, master pseudoterminals were called
fea681da 70.IR /dev/ptyp0 ", ..."
b218b023 71and slave pseudoterminals
fea681da
MK
72.IR /dev/ttyp0 ", ..."
73and one needed lots of preallocated device nodes.
47297adb 74.SH SEE ALSO
fea681da
MK
75.BR getpt (3),
76.BR grantpt (3),
77.BR ptsname (3),
88ab292b
MK
78.BR unlockpt (3),
79.BR pty (7)