flock
Use when cooperating workers need exclusive ownership of a named resource on the same Linux host through an advisory flock mutex.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 4
- Forks
- 2
01 前言 Front Matter
- name
- flock
- description
- Use when cooperating workers need exclusive ownership of a named resource on the same Linux host through an advisory flock mutex.
02 资源文件 1
- 脚本scripts/lock.sh2.3 KB
03 SKILL.md 正文
Named resource mutex
Directives
The sole argument is the exact resource name; quote names containing spaces.
Ownership comes from flock, not metadata. This is cooperative local exclusion,
not a lease, distributed lock or recovery service. Never delete/replace lockfiles,
steal ownership, inspect stale PIDs or kill holders.
Use one resource per dedicated Bash shell. Keep that shell and descriptor 9 alive through the entire protected operation, including across tool calls. Subshells, command substitution and completed one-shot calls cannot retain ownership for later calls. The helper reserves descriptor 9 and sets the shell's umask to 077.
Acquire, work, release
From the repository root (otherwise source the helper by absolute path):
source .agents/skills/flock/scripts/lock.sh
lock 'lcm-daemon-update' || exit "$?"
# Protected work stays in this live shell/session.
exec 9>&-
The helper reads AGENT_THREAD_ID, falling back to CODEX_THREAD_ID for existing
sessions. If absent, obtain the current thread's canonical UUID from the runtime
and export AGENT_THREAD_ID internally. Never invent an identity, substitute a
task name or ask the caller for its UUID. If unavailable, stop without acquiring.
All participants use the same local runtime directory, not isolated fixture
XDG roots: $XDG_RUNTIME_DIR, or /run/user/$(id -u). It must be user-owned with
mode 700. The compatibility namespace codex-locks/ is deliberately unchanged;
renaming it would split existing mutexes. Lock names hash the exact resource bytes
with SHA-256; directory mode is 700 and new files are 600.
The helper rejects symlink/non-regular lockfiles, opens without truncation and
attempts nonblocking exclusive acquisition. Only after success does it replace
metadata through /proc/self/fd/9, targeting the held inode:
thread=0199b4ef-dfde-7a81-b33e-c439d91932d8
acquired=2026-09-06T18:03:42-03:00
resource=powerhome/lcm:worktree-499
Everything after the initial resource= is the verbatim resource, including
embedded newlines, not additional fields.
Status 75 means contention; report observed metadata without modifying it. It may be stale, empty, partial or changing: do not assert a verified current identity. Contact the recorded UUID only when appropriate and permitted. Other failures also prohibit protected work.
Release with exec 9>&-, shell exit, or explicit flock -u 9. Close descriptor 9
in children that must outlive protected work; inherited descriptors can retain
the lock. Leave metadata in place on release; it is historical, not proof of
ownership, even when read during a later contention attempt.
04 同仓库更多 Skills
triage-security-issues
Use when asked to coordinate triage and remediation of a repository's Dependabot malware/vulnerability, GitHub Code Scanning, GitHub Secret Scanning, and Codex Security cloud alerts. Not for starting a new scan or merely authoring or reviewing skills.
triage-fix-all-bugs
Use when asked to coordinate triage and remediation of all currently open native GitHub Bug issues in this repository. Not for a single issue or merely authoring or reviewing skills.
procedural-development
Use when executing or resuming a specified issue or bounded development inventory in a GitHub repository. Not for repository-wide Bug discovery, Epic assessment, or merely authoring or reviewing skills.
lcm-release
Use when explicitly asked to cut or recover a manual LCM release. Not for ordinary version bumps or Changesets release-note/version PR work.
implement-epic
Use when asked to execute or resume an existing planned native GitHub Epic and its required deliverables in this repository. Not for inventing a roadmap, triaging all Bugs, or merely authoring or reviewing skills.