Can I (a) prevent this or (b) clear ptys that should be free?
Answer from Casper :
The solaris FAQ says:
3.39) How can I have more than 48 pseudo-ttys?
Edit /etc/system and add the following line:
* System V pseudo terminals
set pt_cnt = <num>
Halt the system and boot -r.
You can essentially have as many as you like, but you'll probably
run into some other limit somewhere. More than 3000 are supported.
In the unlikely event that you run out of BSD-style ptys,
you can increase them as well. The maximum there is probably
256 as all programs using BSD ptys need to hardcode all the
possible device names and 256 was the maximum previously
found in SunOS 4. BSD ttys are awkward to use and all
programs I found support SYSV ptys without trouble.
* You don't need this. Increasing this value too much usually
* just wastes memory.
set npty = <num>
Halt the system and boot -r.
--- end of excerpt from the FAQ