The number of used pty's as reported in /proc/sys/kernel/pty/nr is getting constantly larger on my 2.6.32 server.

How can I find out which processes are using the ptys, short of killing them one after another and checking if the usage count decreases?

link|improve this question
Have you already tryed "top" command? – Diogo May 13 '11 at 13:37
@diogo_rocha: how does top help? – Nikratio May 13 '11 at 19:38
feedback

2 Answers

up vote 2 down vote accepted

This appears to be a bug in Linux kernel1 - the counter is never decremented, even if ptys are deallocated.

In a standard2 setup, ls /dev/pts should show the actual ptys allocated at the moment, and you can run lsof on them to list all processes using a particular pty (or any other file, for that matter).


1 Fixed in 24d406a, 2011-08-23.
2 Single devpts instance.

link|improve this answer
I don't think it's just that. I have programs failing with "fork() failed: out of pty devices". In these cases, there are only a few ptys in /dev/pts, but /proc/sys/kernel/pty/nr is way above /proc/sys/kernel/pty/max. – Nikratio May 13 '11 at 13:56
@Nikratio: Is it an openvz-based server? Sometimes they have crazy limits; check /proc/user_beancounters. (I've had to deal with a VPS host which had 4 pty limit by default.) – grawity May 13 '11 at 14:07
No, its not a virtual server and the maximum number of ptys is 4096. – Nikratio May 13 '11 at 14:24
@Nikratio: I meant the maximum imposed by OpenVZ, not the one set in kernel.pty.max. – grawity May 13 '11 at 15:26
@Nikratio: In your case, though, I can't answer :( Although the given error message doesn't look like one returned by fork()... The program name would be useful to know. – grawity May 13 '11 at 20:03
feedback

Try using fuser or lsof to see which process is using them.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.