V8/usr/man/man4/pt.4

.TH PT 4
.SH NAME
pt \- interprocess I/O junctor files
.SH DESCRIPTION
These special files, conventionally collected in directory
.IR /dev/pt ,
provide a facility for interprocess communication.
The name `pt' comes from `pseudo-tty,' after vaguely similar mechanisms in
other systems.
.PP
.IR Pt
files
come in even-odd pairs.
If one process opens an odd numbered
.I pt
file, and another opens the corresponding even file,
then data written on one file is available for reading on its partner,
in symmetrical full-duplex fashion.
`Record' boundaries are preserved, where a record is the information
presented in one write call.
Thus a reader attempting to read into a large buffer will receive
chunks of data corresponding to the amounts generated by each call to write.
.PP
The odd-numbered member of a pair is the master.
Masters and slaves differ only in the rules for opening; IO is symmetrical.
Master
.IR pt
files may be opened by at most one process.
Thus the following strategy is appropriate for establishing
communications: one process searches the
.IR /dev/pt
directory
for an odd-numbered file it can open; when it finds one, it publishes
the name in some way.
Typically, it will either fork off a child process that knows the name
by sharing variables, or place the name in some conventional place.
Then one or more slave processes may open the corresponding 
even-numbered file and communicate with the master.
.PP
Once both even- and odd-numbered members of a pair have been opened,
the communications channel is shut down when the file on either side
is closed for the last time.
Thus a master process that expects several unrelated processes
to open the even
.I pt
corresponding to its odd
.I pt
should keep the even
.IR pt
open.
.PP
.IR Pt
files
are stream devices and line discipline modules (see 
.IR stream (4))
may be attached to them.
.SH SEE ALSO
stream(4), ptopen(3)
.SH BUGS
Writes are not atomic, in general.
However, several slow writers may write small messages to a fast reader
and achieve the illusion of atomicity.