Which is the global variable which holds all the environmental variables for getenv() ? In what glibc file is this var filled with env vars ?
I believe it to be **environ but when I set an env var in bash it only ouputs the SSH_AGENT_PID env var. Why is SSH_AGENT_PID set and why is it the only one that is set ?
DOCUMENT_ROOT='/foopath/'; export DOCUMENT_ROOT
int main(void)
{
extern char **environ;
printf("%s\n", *environ); // outputs: SSH_AGENT_PID=2822
}
char **environisNULL-terminated array of strings, so you should try:In other words,
environ[0]is pointer to first env variable,environ[1]to second etc. Last element inenvironarray isNULL.