<s>
In	O
some	O
operating	B-General_Concept
systems	I-General_Concept
,	O
including	O
Unix	B-Application
and	O
Linux	B-Operating_System
,	O
a	O
pseudoterminal	B-Protocol
,	O
pseudotty	O
,	O
or	O
PTY	O
is	O
a	O
pair	O
of	O
pseudo-device	B-Application
endpoints	O
(	O
files	O
)	O
which	O
establish	O
asynchronous	O
,	O
bidirectional	O
communication	O
(	O
IPC	B-Protocol
)	O
channel	O
(	O
with	O
two	O
ports	O
)	O
between	O
two	O
or	O
more	O
processes	O
.	O
</s>
<s>
The	O
master	O
provides	O
means	O
by	O
which	O
a	O
terminal	B-Application
emulator	I-Application
process	B-Operating_System
controls	O
the	O
slave	O
.	O
</s>
<s>
rlogin	B-Application
)	O
and	O
slave	O
files	O
are	O
used	O
by	O
terminal-oriented	O
programs	O
such	O
as	O
shells	O
(	O
e.g.	O
</s>
<s>
bash	B-Operating_System
)	O
as	O
a	O
processes	O
to	O
read/write	O
data	O
back	O
from/to	O
master	O
endpoint	O
.	O
</s>
<s>
Devpts	B-Application
is	O
a	O
Linux	B-Operating_System
Kernel	I-Operating_System
virtual	O
file	O
system	O
used	O
to	O
emulate	O
PTYs	O
connection	O
.	O
</s>
<s>
Linux	B-Operating_System
implementation	O
is	O
based	O
on	O
System	O
V-style	O
terminals	O
(	O
commonly	O
referred	O
as	O
UNIX	B-Application
98	O
pseudoterminals	B-Protocol
)	O
and	O
provides	O
POSIX	O
and	O
the	O
Single	O
Unix	B-Application
Specification	O
API	O
in	O
the	O
form	O
of	O
a	O
function	O
since	O
1998	O
.	O
</s>
<s>
Unix	B-Application
command	O
is	O
typically	O
used	O
to	O
get	O
PTY	O
file	O
path	O
connected	O
to	O
the	O
current	O
standard	O
input	O
.	O
</s>
<s>
Pseudoterminals	B-Protocol
were	O
present	O
in	O
the	O
DEC	O
PDP-6	B-Device
Timesharing	O
Monitor	O
at	O
least	O
as	O
early	O
as	O
1967	O
,	O
and	O
were	O
used	O
to	O
implement	O
batch	O
processing	O
.	O
</s>
<s>
They	O
are	O
described	O
in	O
the	O
documentation	O
for	O
the	O
succeeding	O
TOPS-10	B-Operating_System
on	O
the	O
PDP-10	B-Device
.	O
</s>
<s>
Other	O
DEC	O
operating	B-General_Concept
systems	I-General_Concept
also	O
had	O
PTYs	O
,	O
including	O
RSTS/E	B-Operating_System
for	O
the	O
PDP-11	B-Device
,	O
as	O
did	O
the	O
third-party	O
TENEX	B-Operating_System
operating	B-General_Concept
system	I-General_Concept
for	O
the	O
PDP-10	B-Device
.	O
</s>
<s>
Modern	O
Unix	B-Application
pseudoterminals	B-Protocol
originated	O
in	O
1983	O
during	O
the	O
development	O
of	O
Eighth	B-Operating_System
Edition	I-Operating_System
Unix	I-Operating_System
and	O
were	O
based	O
on	O
a	O
similar	O
feature	O
in	O
TENEX	B-Operating_System
.	O
</s>
<s>
They	O
were	O
part	O
of	O
the	O
4.2	O
release	O
of	O
BSD	B-Operating_System
,	O
with	O
a	O
rather	O
cumbersome	O
interface	O
defined	O
for	O
use	O
.	O
</s>
<s>
T	O
's	O
System	B-Operating_System
V	I-Operating_System
included	O
support	O
for	O
pseudoterminals	B-Protocol
as	O
a	O
driver	O
in	O
their	O
STREAMS	B-Operating_System
device	O
model	O
,	O
along	O
with	O
the	O
pseudoterminal	B-Protocol
multiplexer	O
(	O
)	O
.	O
</s>
<s>
Books	O
The	O
Linux	B-Operating_System
Programming	O
Interface	O
from	O
2010	O
contains	O
an	O
entire	O
chapter	O
(	O
chapter	O
64	O
"	O
Pseudoterminals	B-Protocol
"	O
p1375	O
–	O
1399	O
.	O
)	O
</s>
<s>
explaining	O
pseudoterminals	B-Protocol
.	O
</s>
<s>
The	O
Windows	B-Application
Console	I-Application
was	O
extended	O
to	O
have	O
a	O
PTY	O
interface	O
called	O
ConPTY	O
in	O
2018	O
.	O
</s>
<s>
The	O
role	O
of	O
the	O
terminal	B-Application
emulator	I-Application
process	B-Operating_System
is	O
:	O
</s>
<s>
to	O
feed	O
text	O
input	O
to	O
the	O
master	O
pseudo-device	B-Application
for	O
use	O
by	O
the	O
shell	O
(	O
such	O
as	O
bash	B-Operating_System
)	O
,	O
which	O
is	O
connected	O
to	O
the	O
slave	O
pseudo-device	B-Application
,	O
</s>
<s>
to	O
read	O
text	O
output	O
from	O
the	O
master	O
pseudo-device	B-Application
and	O
show	O
it	O
to	O
the	O
user	O
.	O
</s>
<s>
The	O
terminal	B-Application
emulator	I-Application
process	B-Operating_System
must	O
also	O
handle	O
terminal	O
control	O
commands	O
,	O
e.g.	O
,	O
for	O
resizing	O
the	O
screen	B-Application
.	O
</s>
<s>
Widely	O
used	O
terminal	B-Application
emulator	I-Application
programs	O
include	O
xterm	B-Language
,	O
GNOME	B-Language
Terminal	I-Language
,	O
Konsole	B-Language
,	O
and	O
Terminal	O
(	O
macOS	O
)	O
''	O
.	O
</s>
<s>
Remote	O
login	O
handlers	O
such	O
as	O
ssh	B-Protocol
and	O
telnet	B-Protocol
servers	O
play	O
the	O
same	O
role	O
but	O
communicate	O
with	O
a	O
remote	O
user	O
instead	O
of	O
a	O
local	O
one	O
.	O
</s>
<s>
Screen	B-Application
and	O
Tmux	B-Language
are	O
used	O
to	O
add	O
a	O
session	O
context	O
to	O
a	O
pseudoterminal	B-Protocol
,	O
making	O
for	O
a	O
much	O
more	O
robust	O
and	O
versatile	O
solution	O
.	O
</s>
<s>
In	O
the	O
BSD	B-Operating_System
PTY	O
system	O
,	O
the	O
slave	O
device	O
file	O
,	O
which	O
generally	O
has	O
a	O
name	O
of	O
the	O
form	O
/dev/tty[p-za-e][0-9a-f],	O
supports	O
all	O
system	B-Operating_System
calls	I-Operating_System
applicable	O
to	O
text	O
terminal	O
devices	O
.	O
</s>
<s>
Thus	O
it	O
supports	O
login	B-Operating_System
sessions	I-Operating_System
.	O
</s>
<s>
The	O
master	O
device	O
file	O
,	O
which	O
generally	O
has	O
a	O
name	O
of	O
the	O
form	O
/dev/pty[p-za-e][0-9a-f],	O
is	O
the	O
endpoint	O
for	O
communication	O
with	O
the	O
terminal	B-Application
emulator	I-Application
.	O
</s>
<s>
With	O
this	O
naming	O
scheme	O
,	O
there	O
can	O
be	O
at	O
most	O
256	O
tty	B-Device
pairs	O
.	O
</s>
<s>
Also	O
,	O
finding	O
the	O
first	O
free	O
pty	O
master	O
can	O
be	O
racy	B-Operating_System
unless	O
a	O
locking	O
scheme	O
is	O
adopted	O
.	O
</s>
<s>
For	O
that	O
reason	O
,	O
recent	O
BSD	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
,	O
such	O
as	O
FreeBSD	B-Operating_System
,	O
implement	O
Unix98	O
PTYs	O
.	O
</s>
<s>
BSD	B-Operating_System
PTYs	O
have	O
been	O
rendered	O
obsolete	O
by	O
Unix98	O
ptys	O
whose	O
naming	O
system	O
does	O
not	O
limit	O
the	O
number	O
of	O
pseudo-terminals	O
and	O
access	O
to	O
which	O
occurs	O
without	O
danger	O
of	O
race	B-Operating_System
conditions	I-Operating_System
.	O
</s>
