bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Library open count


From: Flavio Veloso
Subject: Re: Library open count
Date: Mon, 26 Aug 2002 10:29:16 -0300 (BRT)

On 25 Aug 2002, Garrett Kajmowicz wrote:

>       Is there a way/how do I tell how many active opens there are on a given
> libary (ie. /lib/libc.so)?  I would like to do this from a root
> userspace program.  Thank you for your assistance.

 $ lsof -f -- /lib/libc.so.6 | wc -l

This is portable, but requires the lsof program installed, and won't
give you much performance. It may be ok to do quick shell-scripting
but may hurt overall performance if called several times in a row
(e.g. a open libraries top-like program). You must also account for
the two commands opening the library file thenselves, and decrement
the result manually.

If you want to do it in a program them you're out of luck. I'm afraid
it may not exist an easy and portable way of doing that. Maybe
inspecting lsof source may help. In Linux you'll need to scan /proc
and look for the library files in /proc/<pid>/maps (just don't forget
to skip /proc/$$).

-- 
Flávio





reply via email to

[Prev in Thread] Current Thread [Next in Thread]