Expand description
Session lockfile — explicit “this worktree is in use” marker.
Written when a user enters a worktree via gw shell or gw start.
Removed on Drop. Readers verify PID liveness and delete stale files.
Structs§
- Lock
Entry - Serialized lockfile contents describing the session that owns a worktree.
- Session
Lock - RAII guard that removes the lockfile when dropped, provided the lockfile
still belongs to this process. A
Dropthat blindly removed the file would delete another session’s lock if two processes raced the acquire.
Enums§
- Acquire
Error - Outcome of an
acquirecall. Callers may want to distinguish “an active session already owns this worktree” (should block entry) from “we could not write the lockfile at all” (degrade to a warning and proceed).
Constants§
- LOCK_
VERSION - Current on-disk lockfile schema version. A mismatching version makes
the lockfile “foreign” for the reader —
read_and_clean_stalereturns it as-is without removing the file. Writers still check PID ownership, so a foreign-version entry held by another PID is treated as a live foreign lock byacquireand refused.
Functions§
- acquire
- Acquire an exclusive session lock for the given worktree. Cleans up stale
locks; returns
AcquireError::ForeignLockif a live foreign PID holds the lock, orAcquireError::Io/AcquireError::Serdefor I/O / serialization failures. - pid_
alive - Check whether a process with the given PID is currently alive.
- read_
and_ clean_ stale - Read the current lock entry, cleaning up if the owner is gone.