[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reflection and /proc
On Mon, Mar 01, 1999 at 04:10:08PM +0100, Davide Bolcioni wrote:
> Dominik Kubla wrote:
...
> > Right, because the correct answer to your question is getrusage(2).
> I beg your pardon ? What field of struct rusage are you referring to ?
I was referring to the wrong system call, should have said getrlimit(2).
(Well, they are both documented on the same man page, maybe that's the
cause for my mistake...)
Simply calling "(void) getrlimit(RLIMIT_NOFILE,struct_rlimit);"
will return in struct_rlimit.rlim_cur the current number of used file
descriptors, while struct_rlimit.rlim_max gives you your max limit.
That will work with all resources you can set limits on.
As for the call for "maximum value" of file desctriptors in usage at any
time during execution: that is to be done with a syscall-wrapper because
you typically only need this information during development/debugging.
Most profiling libraries give you this option. No need to bloat the kernel.
[...]
> > > A better example: mounted filesystems. Traditional Unix had /etc/mtab,
> > > and the attitude wrt "reflection" (investigation of the state of the
> > > system) was that it is more or less unnecessary: the tool performing
> > > "set" records the state in ordinary files. Still read() and parse.
> >
> > Wrong answer: getmntent(2).
> That was in glibc last time I looked; I am not saying parsing /etc/mtab
> or its cousin /proc/mounts is a bad idea.
Of course you're right, it should have been getmntent(3).
I would be much happier with a system call that returned the internal data
structures instead of the contents of a file. Like OSF's getmntinfo(), but
if i am not wrong this is also a library call. Interesting. I never
realized there was no system call to return you all mounted file systems.
But is that really necessary? The library does perfectly well what we need.
[...]
> The bad solution is nationalized /proc, I gather, so I guess /proc is
> intended for scripts and possibly for C programs: /proc/$$/stat is
> "right" (scanf one-liner), while /proc/$$/status less so (multi-line
> with English). Is this what you mean ?
Yes. But i guess the whole discussion of NLS in the kernel is moot, because
Linus has repeatedly stated that he will never ever accept any such changes.
End of topic as far as i am concerned.
Yours,
Dominik Kubla
-
Linux-future: thinking about the future of the Linux kernel
Archive: http://humbolt.nl.linux.org/lists/
Wish list: http://users.ox.ac.uk/~mert0236/linux-future.html