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)