Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rlgvax.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!trwatf!rlgvax!peter From: peter@rlgvax.UUCP (Peter Klosky) Newsgroups: net.unix,net.unix-wizards Subject: Re: Reading environments in C (I need some help) Message-ID: <629@rlgvax.UUCP> Date: Mon, 20-May-85 11:16:59 EDT Article-I.D.: rlgvax.629 Posted: Mon May 20 11:16:59 1985 Date-Received: Tue, 21-May-85 04:51:02 EDT References: <177@persci.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 19 Xref: linus net.unix:3991 net.unix-wizards:10448 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