Page MenuHomeFreeBSD

lockf: add a -p mode to write the child's pid
ClosedPublic

Authored by kevans on Jun 24 2025, 3:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 8:07 PM
Unknown Object (File)
Sun, Oct 12, 12:18 PM
Unknown Object (File)
Sun, Oct 12, 12:18 PM
Unknown Object (File)
Sun, Oct 12, 12:18 PM
Unknown Object (File)
Sun, Oct 12, 12:18 PM
Unknown Object (File)
Sun, Oct 12, 1:21 AM
Unknown Object (File)
Wed, Oct 8, 9:30 PM
Unknown Object (File)
Mon, Oct 6, 11:53 PM

Details

Summary

If we're going to hold the lock, it can be useful to scribble down the
pid that we spawned off to quickly associate the lock back to the
process that's keeping it open.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65055
Build 61938: arc lint + arc unit

Event Timeline

allanjude added a subscriber: allanjude.

Very useful functionality

This revision is now accepted and ready to land.Jun 24 2025, 3:51 PM
des added inline comments.
usr.bin/lockf/lockf.c
263

Why not just (void)dprintf(lockfd, "%d\n", child)?

usr.bin/lockf/lockf.c
263

I didn't think I really wanted the extra complexity, but looking at the implementation it doesn't seem to be as bad as I was afraid it might be

This revision now requires review to proceed.Jun 24 2025, 5:44 PM
des added inline comments.
usr.bin/lockf/lockf.c
94

I would prefer if the flags were bools but that's cosmetic.

This revision is now accepted and ready to land.Jun 24 2025, 7:58 PM
usr.bin/lockf/lockf.c
94

Yeah, I was eyeballing both this and perhaps the 'kill(getpid(), ....)` pattern in the signal handler for a cosmetic pass.

usr.bin/lockf/lockf.c
124

Adding some flags |= O_TRUNC here as well, in case we're rolling with -k.

This revision was automatically updated to reflect the committed changes.