-1

I have some environmental variables set in my .profile, and thus the variables can be set automatically when I log in. In some special cases, I also need to change some settings using the command "export", just like:

export OMP_NUM_THREADS=3

When I manually edit an environmental variable, run a software which requires the variable with nohup, and then log out. Does the variable turn back at the moment I exit?

Videonauth
  • 33,355
  • 17
  • 105
  • 120

1 Answers1

0

For the program that you started with nohup, no, the variable won't be reset because you logged out (unless it's a program that watches for you logging out and then resets the variable, or some such weirdness).

Each process has its own copy of environment variables. For a process X, other processes cannot typically change X's copy of variables without X's cooperation. This is also why a script cannot change the current shell's variables unless it is sourced.

So, once you start the process, it gets a copy of OMP_NUM_THREADS. What you then do in your shell (including setting OMP_NUM_THREADS to another value, logging out, starting another shell, sacrificing to Cthulhu) won't affect X's environment variables.

muru
  • 197,895
  • 55
  • 485
  • 740