Operating System - HP-UX
1755530 Members
4236 Online
108834 Solutions
New Discussion юеВ

Displaying process environment

 
Mihails Nikitins
Super Advisor

Displaying process environment

Is there any command/way to display all the environment variables for a given process? I understand that I can write some C code to access kernel structures, but this way is too long for me.

Thank you in advance!

Best regards,
Mihails

KISS - Keep It Simple Stupid
5 REPLIES 5
Vincenzo Restuccia
Honored Contributor

Re: Displaying process environment

Try with sysdef
Mihails Nikitins
Super Advisor

Re: Displaying process environment

sysdef prints a very limited list of parameters
and it does not take arguments.
KISS - Keep It Simple Stupid
James R. Ferguson
Acclaimed Contributor

Re: Displaying process environment

Hi Mihails:

Does 'env' for a shell help you?

# env

For a C program how about 'environ' ?, as:

char **environ;

This points to an array of pointers to the strings comprising the environment.

See 'man env' and 'man 5 environ'.

...JRF...
Mihails Nikitins
Super Advisor

Re: Displaying process environment

I run some critical processes that should not be stopped without a serious reason. On the other hand, I need to get faithful information about environment settings for these processes.

E.g., I need to check TZ for all processes, since some them may read settings from custom files.
KISS - Keep It Simple Stupid
Scott Van Kalken
Esteemed Contributor

Re: Displaying process environment

I'm not sure if it would work or not - but you may try attaching to the process with tusc - you'll get a LOT of output, not all of it useful to you, but it may also be able to show you the environment if you're willing to sit down and trace through it.