开发者

Can I use getenv in daemon process under UNIX environment?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜