in reply to Re^3: exec, echo and pipe
in thread exec, echo and pipe

Can you read the environment via ps, pstree or top?

If so how?

The only way I know (on Linux) is via /proc.

ps has an "e" flag:

/home/alex>env - PASSWORD=SECRET sleep 100 & [1] 30765 /home/alex>ps e PID TTY STAT TIME COMMAND 1749 pts/1 Ss 0:00 -bash USER=alex LOGNAME=alex HOME=/home/ale +x PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin M +AIL=/var/mail/alex 5580 pts/1 R+ 0:00 ps e CPLUS_INCLUDE_PATH=/usr/lib64/qt/inclu +de MANPATH=/usr/local/man:/usr/man:/usr/lib64/java/man:/opt/bincimap/ +man:/opt/swish-e/ma 30765 pts/1 S 0:00 sleep 100 PASSWORD=SECRET /home/alex>ps --version procps version 3.2.8 /home/alex>

pstree and top can show command line arguments (using pstree -a), but they can't list the environment.


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)