Skip to content

flock: add first implementation - #697

Open
lmilz wants to merge 5 commits into
uutils:mainfrom
lmilz:flock-implement
Open

lmilz wants to merge 5 commits into
uutils:mainfrom
lmilz:flock-implement

Conversation

@lmilz

@lmilz lmilz commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #694

Adds a first implemention of flock with the core functionality from flock(1):

  • the three forms: flock FILE CMD [ARGS…], flock FILE -c CMD and flock FD
  • -s/-x/-e/-u (the last one wins, as in util-linux), -n/--nb, -w, -E, -c
  • lock files are created if needed; directories and read-only files are opened read-only
  • exit statuses follow util-linux: the -E code on conflict or timeout, the child's status (128+signal if it was killed), and the sysexits codes 64/65/66/69/71 for errors, with the same messages

Differences from util-linux:

  • usage errors exit with 1 (clap) instead of 64
  • -w polls with LOCK_NB every 5 ms instead of using a timer

Not implemented yet (follow-up PRs): -o, -F, --verbose, --fcntl, --start, --length.

@lmilz lmilz changed the title flock: add first implement flock: add first implementation Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement flock

1 participant