Expand description
Cross-platform single-instance process guard.
On startup a process tries to acquire an exclusive, non-blocking lock on a named file under the user’s data dir. Holding the lock keeps a second invocation of the same role from running — the GUI uses it to avoid a duplicate window, the background agent to avoid two processes fighting over the same devices and IPC socket. Each role passes its own lock file name so the GUI and the agent don’t lock each other out. The lock is released by the OS when the process exits, so crash-recovery is free: the next launch reclaims the lock on the leftover file without any cleanup ceremony.
Structs§
- Instance
Guard - Held by
mainfor the duration of the run; dropped on exit (the OS releases the underlying file lock at the same time). The_handlefield is intentionally unused — the value is alive only for itsDropside effect of closing the fd.
Enums§
Functions§
- acquire
- Acquire the single-instance lock on
lock_name(a bare file name resolved underpaths::config_dir). ReturnsOk(guard)on success — keep the guard alive until the process is about to exit.