Reading environments in C (I need some help)

Peter Klosky peter at rlgvax.UUCP
Tue May 21 01:16:59 AEST 1985


XXX
> I would like to know how to create a utility (in C) that, given a
> process i.d. number, can access (print) the environment for that
> process. 'ps -e' does this, and how does it work ...
> We do not have source for ps.

Reading the environment or other data for another process is a fairly
complex task.  You have to find out where the data for the process is
located, and it may be on the swap device or possibly in main memory.
And it may be moved while you are trying to get at it, as well.
The knowledge of where the data is located is in the system's process
table, so you have to read that in, too, and the location of the process
table itself is often determined via the namelist of /unix.
Not to worry, this has all been done before.  For an example of a
program that finds out about other processes, see the "ofiles" program
recently posted to net.sources.  

Peter Klosky
XXX



More information about the Comp.unix mailing list