Is there a way to change the environment variables of another process in Unix?

后端 未结 11 2265
别跟我提以往
别跟我提以往 2020-11-22 15:09

On Unix, is there any way that one process can change another\'s environment variables (assuming they\'re all being run by the same user)? A general solution would be best,

11条回答
  •  天命终不由人
    2020-11-22 15:48

    You probably can do it technically (see other answers), but it might not help you.

    Most programs will expect that env vars cannot be changed from the outside after startup, hence most will probably just read the vars they are interested in at startup and initialize based on that. So changing them afterwards will not make a difference, since the program will never re-read them.

    If you posted this as a concrete problem, you should probably take a different approach. If it was just out of curiosity: Nice question :-).

提交回复
热议问题