且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

改变正在运行的进程的环境变量

更新时间:2022-11-06 18:35:05

在一般情况下,你只能在进程启动时间影响一个进程的环境变量。如果你需要一个变化传达给正在运行的进程,环境是不正确的工具。

In general, you can only influence a process's environment variables at the time the process starts up. If you need to communicate a change to a running process, the environment isn't the right tool.

然而,this问题有一些答案的建议如何克服这种限制。

However, this question has some answers that suggest ways to overcome this limitation.

编辑,以在在问​​题的意见讨论光补充:沟通偶尔改变设置到正在运行的进程的一个比较好的方法是指定地方LOGLEVEL值设置的配置文件,发送SIGHUP的过程,并有这个过程在收到SIGHUP的读取配置文件。

Edited to add in light of discussion in the question's comments: A fairly good way of communicating occasionally changing setup to a running process is to designate a configuration file where the LOGLEVEL value is set, send a SIGHUP to the process, and have the process reread the configuration file upon receipt of SIGHUP.