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
F125020492: D51014.diff
Sat, Aug 2, 11:56 AM
Unknown Object (File)
Tue, Jul 29, 4:22 AM
Unknown Object (File)
Tue, Jul 29, 2:56 AM
Unknown Object (File)
Tue, Jul 29, 2:55 AM
Unknown Object (File)
Tue, Jul 29, 12:05 AM
Unknown Object (File)
Mon, Jul 28, 9:50 PM
Unknown Object (File)
Thu, Jul 10, 6:53 PM
Unknown Object (File)
Mon, Jul 7, 2:19 AM

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 Not Applicable
Unit
Tests Not Applicable

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
264

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

usr.bin/lockf/lockf.c
264

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.