Skip to main content

acquire

Function acquire 

Source
pub fn acquire(
    mana_dir: &Path,
    unit_id: &str,
    pid: u32,
    file_path: &str,
) -> Result<bool, Error>
Expand description

Acquire a lock on a file for a unit agent.

Returns Ok(true) if the lock was acquired, Ok(false) if already locked by another live process. Stale locks (dead PID) are automatically cleaned.

Uses atomic file creation (O_CREAT | O_EXCL) to prevent TOCTOU races when multiple agents attempt to lock the same file concurrently.