man-pages/man4/pts.4

73 lines
2.3 KiB
Groff
Raw Normal View History

2004-11-03 13:51:07 +00:00
.\" Hey Emacs! This file is -*- nroff -*- source.
.\" This man page was written by Jeremy Phelps <jphelps@notreached.net>.
.\" Notes added - aeb
.\" Redistribute and revise at will.
.\"
2007-05-18 09:11:21 +00:00
.TH PTS 4 2002-10-09 "Linux" "Linux Programmer's Manual"
2004-11-03 13:51:07 +00:00
.SH NAME
ptmx, pts \- psuedoterminal master and slave
2004-11-03 13:51:07 +00:00
.SH DESCRIPTION
2005-11-02 13:55:25 +00:00
The file \fI/dev/ptmx\fP is a character file with major number 5 and
2004-11-03 13:51:07 +00:00
minor number 2, usually of mode 0666 and owner.group of root.root.
It is used to create a psuedoterminal master and slave pair.
2004-11-03 13:51:07 +00:00
.PP
2005-11-02 13:55:25 +00:00
When a process opens \fI/dev/ptmx\fP, it gets a file
descriptor for a psuedoterminal master (PTM),
and a psuedoterminal slave (PTS) device is created in the
2004-11-03 13:51:07 +00:00
.I /dev/pts
directory.
Each file descriptor obtained by opening \fI/dev/ptmx\fP
2004-11-03 13:51:07 +00:00
is an independent PTM with its own associated PTS, whose path can
be found by passing the descriptor to
.BR ptsname (3).
.PP
Before opening the psuedoterminal slave, you must pass the master's file
2004-11-03 13:51:07 +00:00
descriptor to
.BR grantpt (3)
and
.BR unlockpt (3).
.PP
Once both the psuedoterminal master and slave are open, the slave provides
2004-11-03 13:51:07 +00:00
processes with an interface that is identical to that of a real terminal.
.PP
Data written to the slave is presented on the master descriptor as input.
Data written to the master is presented to the slave as input.
.PP
In practice, psuedoterminals are used for implementing terminal emulators
such as
2004-11-03 13:51:07 +00:00
.BR xterm (1),
in which data read from the psuedoterminal master is interpreted by the
2004-11-03 13:51:07 +00:00
application in the same way
a real terminal would interpret the data, and for implementing remote-login
programs such as
.BR sshd (8),
in which data read from the psuedoterminal master is sent across the network
2004-11-03 13:51:07 +00:00
to a client program that is connected to a terminal or terminal emulator.
.PP
Psuedoterminals can also be used to send input to programs that normally
2004-11-03 13:51:07 +00:00
refuse to read input from pipes (such as
.BR su (1),
2004-11-03 13:51:07 +00:00
and
.BR passwd (1)).
2004-11-03 13:51:07 +00:00
.SH FILES
.IR /dev/ptmx ,
.I /dev/pts/*
.SH NOTES
The Linux support for the above (known as UNIX 98 psuedoterminal naming)
2004-11-03 13:51:07 +00:00
is done using the
.I devpts
2008-03-19 07:26:08 +00:00
file system, that should be mounted on
2004-11-03 13:51:07 +00:00
.IR /dev/pts .
.LP
Before this UNIX 98 scheme, master psuedoterminals were called
2004-11-03 13:51:07 +00:00
.IR /dev/ptyp0 ", ..."
and slave psuedoterminals
2004-11-03 13:51:07 +00:00
.IR /dev/ttyp0 ", ..."
and one needed lots of preallocated device nodes.
.SH "SEE ALSO"
.BR getpt (3),
.BR grantpt (3),
.BR ptsname (3),
2005-10-10 13:14:12 +00:00
.BR unlockpt (3),
.BR pty (7)