Skip to main content

env_mutation_lock

Function env_mutation_lock 

Source
pub fn env_mutation_lock() -> &'static Mutex<()>
Expand description

Returns a process-wide mutex that serializes mutations of std::env across threads.

std::env::set_var and remove_var are not thread-safe in the presence of concurrent reads from other threads. Code that mutates the process environment (test setup, startup-time configuration, #[kithara::test] proc-macro env-guard) should hold this lock across the mutation to prevent races.