pseudo-tty conventions

T. Dave Hudson tdh at frog.UUCP
Wed Jun 13 11:41:00 AEST 1990


(I'm not sure where a discussion of the following belongs, and so am
not redirecting followups.)

I received replies from
	omerzu at quando.quantum.de
	andyb at coat.com
	lamy at cs.utoronto.ca
	brnstnd at stealth.acf.nyu.edu
All of these used different schemes, presumably all of which break
would-be-portable code.

1) Nixdorf TARGON/35-50 w/ Pyramid OS
	Naming convention:
		/dev/[pt]ty[p-z][0-9a-f]
	Comments:
		This only allows for 176 ptys.
2) Sequent, w/ DYNIX
	Naming convention (ordering of a-z vs. A-Z reflects numbering):
		/dev/[pt]ty[p-wP-W][0-9a-zA-Z]
	Allocation convention:
		int getpseudotty(char **slave, char **master)
		(returns master r/w FD or -1)
	Misc:
		1) similar scheme starting with ttyx0 for X.25 logins
		2) ispseudotty(char *ttyname)
		   (with ttyname stripped of "/dev/" prefix)
	Comments:
		This allows for 992 ptys.  I also like the idea of
		encapsulating the allocation of ptys.
3) MIPS and SGI, w/ RISC/os
	Naming convention (slave only):
		/dev/ttyqn
		(n is decimal number)
	Allocation convention:
		1) open /dev/ptc, fstat() it, use minor dev for slave
		2) open /dev/ptcm, open /dev/ptcm[0-9] until matching
		   (st_rdev) major device#, multiplying the last digit
		   by 256 and adding the minor dev# for the slave
	Comments:
		The first scheme allows for 256 ptys, the latter for
		64K-1.  I like saving on almost all of pty* device
		files.  It looks like this breaks SVID's utmp.h.
4) Dan Bernstein's pty program
	Naming convention:
		/dev/[pt]ty[p-za-o][0-9a-f]
		(but with PTY1 and PTY2 ranges in Makefile)
	Allocation convention:
		Dan is writing a UNIX-domain sockets daemon for
		allocating pty descriptors, and would re-write for
		streams.
	Comments:
		This allows for at least 416 ptys.  Dan claims that
		under a /dev/[pt]typ<decimal#> scheme "[m]any
		utilities will die horribly if tty extensions are
		larger than two characters", but I don't see how any
		scheme here wouldn't fail to be portable.

I like the Sequent/DYNIX allocation convention.  The only feature that
it lacks is an overall pty index (such as is used by MIPS and SGI), a
feature I've seen used here under a dumb-terminal windows program used
internally.  This lack can be compensated for by using *stat() to get
the device#, playing some games to avoid a large index.  It is not
necessary to accept the Sequent/DYNIX naming convention, since this
can be hidden.

It looks like it is unnecessary for a pty's name to exceed 10
characters, but the SVID limit in utmp.h is 11 characters anyway, if
a character is reserved for a terminating ASCII NUL.

In an ideal world, I'd have "int getpseudotty(char *slave)", with
"slave" (perhaps pre-filled) a 12 char array to be NUL-terminated, and
possibly avoiding the use of a master-side device entirely.

There seem to be no widely accepted pty conventions.  I'd like to see
some discussion before deciding what conventions to use.

				David Hudson



More information about the Comp.unix.questions mailing list