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