Is a race condition possible when updating the environment variable PATH? Is it avoidable?
concurrency, environment-variables, path, race-condition, windows
Solution
No, there's no danger of this. Every process has its own environment. So they'll just update their own copy of the PATH environment variable. Such changes are also not persisted and disappear when the process terminates.
Making global changes to the environment requires writing the registry. Otherwise exposed in the System applet in Control Panel. Such changes require a logout + login to be effective for every process.
Problem
If two or more applications running on Windows are trying to append a folder name to the environment variable `PATH` at the same time, is it possible to get a race condition such that one of the values being appended is lost? What is the standard way to avoid these race conditions?