Re: reading /proc values thorugh C code



On 18 Feb., 18:48, Joe Pfeiffer <pfeif...@xxxxxxxxxxx> wrote:
uday kiran <s.udaiki...@xxxxxxxxx> writes:
Hi all,
I have been looking for quite some time to read /proc entries through
a c code. I understand that there are directories with pids. If there
is a library or a kernel structure that lets us to do so. Please let
me know.

You just read them. If you want to read /proc, you open it with
opendir() and read the entries with readdir(). If you want to read
/proc/1, you do the same. If you want to read /proc/1/maps, you open
it with open() and read it with read().
I agree. There is one thing: /proc changes dynamic.
You could read an entry with readdir() and when you try to open() it,
the file has disappeared (I know this can happen everywhere, but
elsewhere it does not happen so often). As good programmer you
check the result of open() and there will be no problem...

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch.
.



Relevant Pages