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