systemg 0.33.0

A simple process manager.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::sync::{Mutex, OnceLock};

/// Global lock for environment variable modifications in tests.
/// All tests that modify environment variables (especially HOME) should acquire this lock
/// to prevent race conditions between parallel test executions.
pub static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();

/// Acquires the global environment lock for safe environment variable modifications in tests.
///
/// This function should be called by any test that modifies environment variables
/// to prevent race conditions in parallel test execution.
pub fn env_lock() -> std::sync::MutexGuard<'static, ()> {
    ENV_LOCK
        .get_or_init(|| Mutex::new(()))
        .lock()
        .unwrap_or_else(|poisoned| poisoned.into_inner())
}