Question

I am writing a daemon process (let's say pA), which is kicked off by a another process(let's say pB), in this daemon pA, I want to use getenv to access a evn variable defined in .cshrc, but to my surprise, getenv returns NULL in pA. I write a another standalone program to use getenv to access this same variable, and it works fine. So I want to ask if getenv can't work in daemon process? How can I access env variables in daemons? thank you

Was it helpful?

Solution

Probably not relevant any more, but for the people that come here through search - see the answer here: https://stackoverflow.com/a/11850426/397604

In Linux, if you only set the variable (or export it) in a bash session, it will be available to a kind of "sub" session, which is only available to the command you just executed, and nothing else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top