Page MenuHomeFreeBSD

daemon: truncate the pidfile when we're waiting to restart child
ClosedPublic

Authored by kevans on Oct 8 2024, 5:23 AM.
Tags
None
Referenced Files
F103015761: D47003.diff
Tue, Nov 19, 8:47 PM
Unknown Object (File)
Mon, Nov 18, 2:31 PM
Unknown Object (File)
Thu, Nov 14, 8:15 PM
Unknown Object (File)
Tue, Nov 12, 1:39 PM
Unknown Object (File)
Tue, Oct 22, 8:35 AM
Unknown Object (File)
Oct 20 2024, 4:33 PM
Unknown Object (File)
Oct 16 2024, 9:06 PM
Unknown Object (File)
Oct 16 2024, 9:02 PM
Subscribers

Details

Summary

We need to be able to test some more restart behavior that depends on
knowing specifically where we're at (inside the event loop or outside of the
event loop). Truncate the pidfile until the process is restarted to give
the test a clean marker rather than having to add arbitrary delays and
hoping for the best.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Oct 8 2024, 5:23 AM

rather than having to add arbitrary delays and hoping for the best.

From my reading, the test is still kinda doing that - daemon will sleep for 1s in between restarts by default, so that gives you a short window to check for a truncated pidfile. Were you going to take advantage of this change in other tests?

I think this change is probably ok, but I don't quite understand the justification.

usr.sbin/daemon/daemon.c
538

Is there a specific reason we don't just unlink the child pidfile?

854

This could reasonably live in libutil, but it's simple enough that this is fine for now.

rather than having to add arbitrary delays and hoping for the best.

From my reading, the test is still kinda doing that - daemon will sleep for 1s in between restarts by default, so that gives you a short window to check for a truncated pidfile. Were you going to take advantage of this change in other tests?

I think this change is probably ok, but I don't quite understand the justification.

It's a bit more clear after reading D47005.

This revision is now accepted and ready to land.Oct 8 2024, 12:12 PM
usr.sbin/daemon/daemon.c
538

The pidfile API takes a lock on the pidfile while we have it open- I wanted to avoid opening the opportunity for another daemon(8) to pop in and take the path since this is pretty much just an aide for testing.