If I search for counting the number of threads an application has, all the answers involve external programs like top
. I want to count the threads within the ap
Use top -H. But chances are, if you can't read proc, top won't work anyway. If thats the case, there is no easy way and it would depend on your specific system.
You could write a tiny wrapper for pthread_create that counts created threads and link against that wrapper after you linked against the immutable library.
If you can't read /proc
you are a bit in trouble, unless your program communicate with another program which reads /proc
If you don't want to read /proc because of portability concerns, you might use a library which abstracts that a bit, like libproc
does