Number of ptys (was prwopen: A popen-like routine using ptys)

Chris Torek chris at umcp-cs.UUCP
Tue Mar 4 20:52:26 AEST 1986


The posted `prwopen' routine has inside it a bit of short-sightedness
that has long been propagated from what was probably purely an
efficiency hack.  Specifically, in its pty scan routine, it says
(paraphrased):

	for (c = 'p'; c <= 's'; c++) {
		sprintf(name, "/dev/pty%c0", c);
		if (stat(name, &st))
			break;
		...
		if (ok)
			goto gotpty;
	}
	no ptys are available
	do something special

This puts a limit of 64 on the number of ptys that will be tried.
64 might seem like a lot on a 780, but a 780 is not a very big
machine.  Someday, someone will run out.

That day has already come.  We have 80 ptys on our 8600.

The middle condition in the for loop should simply be removed.  If
there is no /dev/ptyt0, the stat will fail.  Sure, that is more
expensive than the test `c <= 's'', but who cares?  And if there
IS another set of ptys, why not try them?

(Of course, there really should be a better way to do the whole
thing.  But until then, why put artificial limitations on what we
have now?)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.unix.wizards mailing list