[Previous] [Contents] [Next]

Dev.pty

Pseudo-tty driver (QNX)

Syntax:

Dev.pty [-C number] [-I number] [-O number]
        [-l letter] [-n number] [-N mastername[,slavename] &

Options:

-C number
The size of the canonical input buffer (default is 256).
-I number
The size of the raw input buffer (default is 512).
-l letter
("el") The last letter of the device name (default is p, which results in /dev/ttyp). Other choices are q, r, or s.
-n number
The maximum number of pseudo tty pairs (default is 4). Device pairs will be numbered incrementally in hexadecimal notation. Values greater than 16 (f) are possible but are not recommended for UNIX compatibility reasons.
-N mastername[,slavename]
The name to use for the master (and optionally, slave) sides of the pseudo tty devices (default is /dev/pty,/dev/tty). If full paths (i.e. ones that include the directory under which the devices should be registered) are not specified, the names will implicitly be registered under /dev.
-O number
The size of the output buffer (default is 512).

Description:

The Dev.pty driver manages pseudo tty devices (called ptys) in a QNX system. Pseudo devices are allocated in pairs; the members of each pair are internally connected to each other. Any data written to the master side (e.g. /dev/ptyp0) will be available for reading on the slave side (e.g. /dev/ttyp0).

Typically, a program will open the master side of a pty for read/write and then launch another program (e.g. a Shell) on the corresponding slave device. The slave program will think it's running on a normal tty device. Nevertheless, all the data that the slave writes will go to the master and all the data that the slave reads will really be data generated by the master.

Remember that Dev.pty must be run as root and cannot be started until the Device Manager (Dev) has been started.


Note: QNX programs that open ptys (e.g. telnetd, rlogind, etc.) search an extended set of ptys. The search order is:
  • /dev/pty[pqrs][0-f]
  • /dev/pty/0/p[0-ff]
  • /dev/pty/1/p[0-ff]
  • /dev/pty/2/p[0-ff]
    ...
  • /dev/pty/999/p[0-ff]
The search stops upon encountering a non-existent blank directory. If the directory /dev/pty/1 doesn't exist, the search will stop there rather than go on to search /dev/pty/2 and so on.

Applications that wish to use the same pty search ordering can open ptys using the open_pty() function in the unix library:

int open_pty(int *masterfd, int *slavefd,
             char *name, struct termios *termp,
             struct winsize *winp);
(The arguments name, termp and winp may be NULL.)

Examples:

Start Dev.pty; use defaults (this would create /dev/ptyp0 through /dev/ptyp3 and /dev/ttyp0 through /dev/ttyp3):

    Dev.pty &

Create 16 device pairs called /dev/ptyq0 through /dev/ptyqf and /dev/ttyq0 through /dev/ttyqf:

    Dev.pty -n 16 -l q &

Create 32 device pairs under a directory /dev/pseudo that is managed by a second Dev administrator. Name the devices /dev/pseudo/m0 through /dev/pseudo/m1f and /dev/pseudo/q0 through /dev/pseudo/q1f:

    Dev -N /dev/pseudo -n65 &
    Dev.pty -n32 -N /dev/pseudo/m,/dev/pseudo/s &

Files:

Dev.pty closes its standard input, standard output and standard error immediately after startup initializations have been completed. An error message is written to standard error if an initialization problem is encountered.

Dev.pty will cause Dev to adopt a number of pairs of character special files under its directory (/dev). Usually pairs will be named ptycn/ttycn where c is p (the default) or the letter specified by the -l option, and n will range from 1 to the number of pseudo-tty devices specified by the Dev.pty -n option.

Exit status:

Dev.pty will terminate only upon receiving a signal, encountering a problem during startup, or having to fork() due to not being started in the "background" (i.e. the ampersand [&] was missing on its command-line invocation).

0
received a signal and performed a clean shutdown OR not started in the background from the shell and successfully forked to another process.
>0
An error occurred during startup. An error message was written to standard error.

Note:

A common cause of failure on startup is that Dev has hit its maximum number of devices and rejects Dev.pty's attempt to register. If this happens, increase the value of Dev's -n option.


See also:

Dev, Dev.*, stty, tinit


[Previous] [Contents] [Next]