COHERENT manpages

This page displays the COHERENT manpage for pty [Device driver for pseudoterminals].

List of available manpages
Index


pty -- Device Driver

Device driver for pseudoterminals

The COHERENT device driver pty lets  your system support up to 128 pairs of
pseudoterminals, or ptys.

A pseudoterminal is a means of  letting a process masquerade as a terminal.
For example,  when you run the  program xterm under X,  that program passes
what you type into COHERENT through a pseudoterminal device.

Each pseudoterminal  consists of a pair  of devices: a master  device and a
slave  device.  The  program that  is  accepting input  from a  human at  a
keyboard (e.g.,  xterm) is ``plugged''  into the slave  device; the program
that is accepting and processing the  input (e.g., a shell) is plugged into
the master  device.  The following  diagram shows how this  pair of devices
relate to each other:



        app     master          line    slave   app
        using    pty            disc.   pty     using
        master  device          module  device  slave
                    \....................../
                            pty driver

As you can see, the slave device talks to the keyboard through a sub-module
that   performs  line   discipline.    Line-discipline  handles   backspace
characters, handles special  interrupt characters (such as <ctrl-C>),
and converts line-feed characters into carriage-return--line-feed character
pairs: it  bundles what you type  into a package that can  be passed to the
master application and processed.

Only one process  at a time can open a  master device; the device is opened
as  soon as  requested.  Several  processes  can open  a slave  device, but
blocks until  the matching  master device has  been open.  When  blocked in
this way, the slave is said to be ``waiting for pseudocarrier.''

An attempt to read a master  device when no input is available, or to write
to a  master device when  the slave cannot  accept data, will  block unless
nonblocking I/O  has been specifically requested; in  this case, the system
calls read() or write() fail and errno is set to EAGAIN.

You can use  the system call ioctl() on slave  devices with all valid line-
discipline  commands,  including  TCGETA,  TCSETA,  TCSETAW,  TCSETAF,  and
TCFLSH. There are no valid ioctl() commands for master devices.

The system call  poll() is allowed with both master  and slave pty devices.
However, priority polls (POLLPRI) are not supported.

Master  devices  are  named  /dev/pty[p-w][0-f]. Corresponding  slaves  are
/dev/tty[p-w][0-f]. Like  any other device, each pty has  a major and minor
number.   The   major  number  is  9  (PTY_MAJOR   in  system  header  file
<sys/devices.h>).  For  slave  devices,  minor numbers  are  assigned
according to the following scheme:

               device   Major number   Minor number
               /dev/ttyp0     9              0
               /dev/ttyp1     9              1
               ...

               /dev/ttyp9     9              9
               /dev/ttypa     9             10
               /dev/ttypb     9             11
               ...

               /dev/ttypf     9             15
               /dev/ttyq0     9             16
               ...

               /dev/ttyw0     9             112
               ...

               /dev/ttywf     9             127

For master devices, use pty instead  of tty in the device name, and add 128
to the minor number.

The configurable parameter NUPTY_SPEC sets the number of pty pairs that may
be used.  The  default is eight.  If you want  to change this value, invoke
the script  /etc/conf/pty/mkdev and enter the new  value at the appropriate
prompt.  Then  use the command /etc/conf/bin/idmkcoh to  build a new kernel
that incorporates this change; when the  new kernel is built, boot it.  For
details, see the Lexicon entry for the command idmkcoh.

Specifying a value  of zero for NUPTY_SPEC will cause  the pty device to be
omitted from the next kernel that idmkcoh generates.

See Also

device drivers