Created attachment 232656 [details] Add support for locking FDs to lockf Inspired by flock on Linux, teach lockf the trick of locking an already open FD so sections of shell scripts can be locked (or just avoid having to wrap a shell script in a lockf or shell instance).
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=09a7fe0a5523d53ff6c26ddef9a947f293e18c22 commit 09a7fe0a5523d53ff6c26ddef9a947f293e18c22 Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2023-11-22 07:46:14 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2023-11-26 04:15:05 +0000 lockf: allow locking file descriptors This is most useful inside a shell script, allowing one to lock just portions of a script rather than having to wrap the entire script in a lock. PR: 262738 Reviewed by: 0mp, allanjude (both previous versions) Co-authored-by: Daniel O'Connor <darius@dons.net.au> Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42718 usr.bin/lockf/lockf.1 | 63 ++++++++++++++++++- usr.bin/lockf/lockf.c | 128 +++++++++++++++++++++++++++++++++----- usr.bin/lockf/tests/lockf_test.sh | 91 +++++++++++++++++++++++++++ 3 files changed, 266 insertions(+), 16 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=63b86eb6fa935ecf94b9a0f1842b56a223f151be commit 63b86eb6fa935ecf94b9a0f1842b56a223f151be Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2023-11-22 07:46:14 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2023-12-15 00:58:29 +0000 lockf: allow locking file descriptors This is most useful inside a shell script, allowing one to lock just portions of a script rather than having to wrap the entire script in a lock. PR: 262738 Reviewed by: 0mp, allanjude (both previous versions) Co-authored-by: Daniel O'Connor <darius@dons.net.au> Sponsored by: Klara, Inc. (cherry picked from commit 09a7fe0a5523d53ff6c26ddef9a947f293e18c22) usr.bin/lockf/lockf.1 | 63 ++++++++++++++++++- usr.bin/lockf/lockf.c | 128 +++++++++++++++++++++++++++++++++----- usr.bin/lockf/tests/lockf_test.sh | 91 +++++++++++++++++++++++++++ 3 files changed, 266 insertions(+), 16 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=663424957d8079d514d127ac8c2fb65b247960be commit 663424957d8079d514d127ac8c2fb65b247960be Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2023-11-22 07:46:14 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2023-12-15 00:59:25 +0000 lockf: allow locking file descriptors This is most useful inside a shell script, allowing one to lock just portions of a script rather than having to wrap the entire script in a lock. PR: 262738 Reviewed by: 0mp, allanjude (both previous versions) Co-authored-by: Daniel O'Connor <darius@dons.net.au> Sponsored by: Klara, Inc. (cherry picked from commit 09a7fe0a5523d53ff6c26ddef9a947f293e18c22) usr.bin/lockf/lockf.1 | 63 ++++++++++++++++++- usr.bin/lockf/lockf.c | 128 +++++++++++++++++++++++++++++++++----- usr.bin/lockf/tests/lockf_test.sh | 91 +++++++++++++++++++++++++++ 3 files changed, 266 insertions(+), 16 deletions(-)
Thanks for the patch!