yoni
yoni

Reputation: 106

change environment variable on a running process in mac

I have a running process on mac and I want to change is environment variable from out side the process, using some command line utility.

How can I do that?

Upvotes: 2

Views: 1266

Answers (1)

Kurtis Rader
Kurtis Rader

Reputation: 7469

You cannot change the environment variables of a running process via an external utility. Doing so would require the utility to modify the address space of the process. Note that this is not a limitation of macOS. This is a limitation of the UNIX process model. When a UNIX process is created by the kernel the environment variables are put in its address space; typically near the top of the stack. They are not stored in the kernel data structures for the process. And thus there are no system calls for getting or setting those vars. Which means there is no way for one process to affect the env vars of a second process other than at the time the second process is created via execve() or a related syscall.

Upvotes: 6

Related Questions