문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top