150 lines
3.9 KiB
HTML
150 lines
3.9 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of PTS</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>PTS</H1>
|
|
Section: Linux Programmer's Manual (4)<BR>Updated: 2016-03-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
ptmx, pts - pseudoterminal master and slave
|
|
<A NAME="lbAC"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The file
|
|
<I>/dev/ptmx</I>
|
|
|
|
is a character file with major number 5 and
|
|
minor number 2, usually with mode 0666 and ownership root:root.
|
|
It is used to create a pseudoterminal master and slave pair.
|
|
<P>
|
|
|
|
When a process opens
|
|
<I>/dev/ptmx</I>,
|
|
|
|
it gets a file
|
|
descriptor for a pseudoterminal master (PTM),
|
|
and a pseudoterminal slave (PTS) device is created in the
|
|
<I>/dev/pts</I>
|
|
|
|
directory.
|
|
Each file descriptor obtained by opening
|
|
<I>/dev/ptmx</I>
|
|
|
|
is an independent PTM with its own associated PTS, whose path can
|
|
be found by passing the file descriptor to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ptsname">ptsname</A></B>(3).
|
|
|
|
<P>
|
|
|
|
Before opening the pseudoterminal slave, you must pass the master's file
|
|
descriptor to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+grantpt">grantpt</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+unlockpt">unlockpt</A></B>(3).
|
|
|
|
<P>
|
|
|
|
Once both the pseudoterminal master and slave are open, the slave provides
|
|
processes with an interface that is identical to that of a real terminal.
|
|
<P>
|
|
|
|
Data written to the slave is presented on the master file descriptor as input.
|
|
Data written to the master is presented to the slave as input.
|
|
<P>
|
|
|
|
In practice, pseudoterminals are used for implementing terminal emulators
|
|
such as
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1),
|
|
|
|
in which data read from the pseudoterminal master is interpreted by the
|
|
application in the same way
|
|
a real terminal would interpret the data, and for implementing remote-login
|
|
programs such as
|
|
<B><A HREF="/cgi-bin/man/man2html?8+sshd">sshd</A></B>(8),
|
|
|
|
in which data read from the pseudoterminal master is sent across the network
|
|
to a client program that is connected to a terminal or terminal emulator.
|
|
<P>
|
|
|
|
Pseudoterminals can also be used to send input to programs that normally
|
|
refuse to read input from pipes (such as
|
|
<B><A HREF="/cgi-bin/man/man2html?1+su">su</A></B>(1),
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?1+passwd">passwd</A></B>(1)).
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
<I>/dev/ptmx</I>,
|
|
|
|
<I>/dev/pts/*</I>
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
The Linux support for the above (known as UNIX 98 pseudoterminal naming)
|
|
is done using the
|
|
<I>devpts</I>
|
|
|
|
filesystem, that should be mounted on
|
|
<I>/dev/pts</I>.
|
|
|
|
<P>
|
|
|
|
Before this UNIX 98 scheme, master pseudoterminals were called
|
|
<I>/dev/ptyp0</I>, ...
|
|
|
|
and slave pseudoterminals
|
|
<I>/dev/ttyp0</I>, ...
|
|
|
|
and one needed lots of preallocated device nodes.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getpt">getpt</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+grantpt">grantpt</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ptsname">ptsname</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+unlockpt">unlockpt</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+pty">pty</A></B>(7)
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">DESCRIPTION</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">FILES</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">NOTES</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">SEE ALSO</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:02 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|