[Cialug] RH pty #s

Zachary Kotlarek zach at kotlarek.com
Wed Jan 25 18:01:20 CST 2012


On Jan 25, 2012, at 1:38 PM, L. V. Lammert wrote:

> Ran into an intersting situation today, .. found out that some s/w is
> counting the number of users by looking at the pts assigned.
> 
> Can someone point me at 'official' documentation that shows how they are
> assigned? The problem is, in this case, that the s/w is looking for a pts
> 24 to indicate that more than 24 users are online, however it happens
> about 15 users depending on various sequences of logins and logouts.
> 
> If we can find any good documentation of how they are assigned on RH, we
> can go back to the vendor and get then to increase the license count.



PTY assignment is a kernel issue; there's nothing RH-specific about it. The feature you're looking for is typically called UNIX98 PTYs in the kernel docs/source.

It's not official documentation, but if it's of any use I know that PTYs cannot change numbers after they are opened, so when someone logs out after you've logged in your PTY number does not go down. This is trivial to demonstrate -- just log in a bunch of users (or the same user a bunch of times) and then log out all but the last session. That last session will still have a high PTY number even though the number of open PTYs is much lower.

Hence the PTY number should indicate the number of PTYs open at the time your PTY was opened, but that's not necessarily the same as the number of PTYs currently open. (Also note that the number is not guaranteed to mean anything in general -- devpts happens to use numbers, but in the past pty devices had letters not numbers in their names, and their device minor number isn't intended to reflect any other system attribute)

You can examine open PTYs in /dev/pts (or wherever your devpts file system is mounted). A correct count of open PTYs would be equal to the count of device files in that folder with major number 136. Or in a typical configuration, the total number of files in that folder, minus 1 for the master PTY file.

FYI: You can mount multiple, independent devpts filesystems (so that PTYs from one don't show up in the other). But I don't know if they share numbers or not; they may simply hide out-of-scope PTYs while sharing an underlying numbering scheme. If they don't share numbers you may be able to work around this limitation with a chroot wrapper that gives each launched instance of the app its own /dev/pts tree and enforcing your license limit through other policies.

	Zach

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2746 bytes
Desc: not available
URL: <http://cialug.org/pipermail/cialug/attachments/20120125/cacf3c3d/attachment.bin>


More information about the Cialug mailing list