externally accessing process environment

Michael C. Berch mcb at styx.UUCP
Wed Apr 9 10:18:20 AEST 1986


In article <171 at minnie.UUCP> chris at minnie.UUCP (Chris Grevstad) writes:
> Running 4.2BSD on an Integrated Solutions 68010 machine.  What I would
> like to know is if there is some way for a process to examine the
> environment of a non-related process.  What I want in particular is a
> way to determine, from an external process, a terminal's type without 
> resorting to the possibly inaccurate file /etc/ttytype. 
> The examining process is running as root.

There's undoubtedly a more elegant way to do this, but you can get the
entire environment of a process using the 'e' option of ps(1). (i.e.,
"ps ewwNNNNN" where NNNNN is the process number. The 'ww' is to get
the "widest" display so the lengthy string is not truncated.
This is known to work on a VAX 780 running 4.2BSD.

You can fork off a ps(1) and read the output through a pipe, muck
around in the result to find TERM, and you're off to the races!

Michael C. Berch
Control Data Corp. / Lawrence Livermore Natl. Laboratory
ARPA: mcb at lll-tis-b.ARPA
UUCP: {ihnp4,dual}!lll-lcc!styx!mcb



More information about the Comp.unix.wizards mailing list