Find out which environment variables used by a command
Answer a question
In a Linux environment (in my case XUbuntu), is there a way to find out which environment variables are accessed by a command which is run from the console?
It must be possible to find out about these variables, as someone has to provide the values to the program. But is there some default method to do this?
The program in question here is xprintidle.
Answers
Assuming you want the variables actually used by some process running a command, you could use ltrace and look for calls to getenv:
$ ltrace -e getenv ./your_program
Of course, the argument to getenv can be computed (so you cannot really predict it).
However, some (old or strange) applications might use the environ global, or the third optional argument to main; and some applications even change their environment using putenv, setenv or unsetenv (all 3 being the libc functions, not the shell builtin).
but xprintidle is mostly interacting with the Xorg server. I'm surprised you are expecting it to use many environment variables (except DISPLAY).
更多推荐




所有评论(0)