Page MenuHomeFreeBSD

lockf: switch to a SIGCHLD model for reaping child
AcceptedPublic

Authored by kevans on Tue, Jun 24, 11:19 PM.
Tags
None
Referenced Files
F122454548: D51024.id.diff
Sat, Jul 5, 11:21 AM
Unknown Object (File)
Tue, Jul 1, 10:44 PM
Unknown Object (File)
Tue, Jul 1, 5:09 PM
Unknown Object (File)
Tue, Jul 1, 5:09 PM
Unknown Object (File)
Tue, Jul 1, 5:09 PM
Unknown Object (File)
Tue, Jul 1, 5:09 PM
Unknown Object (File)
Tue, Jul 1, 5:09 PM
Unknown Object (File)
Mon, Jun 30, 4:51 PM
Subscribers

Details

Reviewers
allanjude
des
kib
Summary

A future change will add a -T flag to forward SIGTERM along to the
child before we cleanup and terminate ourselves. Using a SIGCHLD
handler to do that with SIGTERM blocked only while the child is actively
being collected will enable us to safely do so without having to worry
that our pid is potentially invalid.

Add a test that concisely checks that the child's error is properly
bubbled up to the caller.

Diff Detail

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

Event Timeline

kevans added a subscriber: kib.

Adding @kib to validate fence usage.

usr.bin/lockf/lockf.c
251

You fork before setting the handler for SIGCHLD. See aa8cdb7cae7b7550d5cb8 for the fix for the same bug.

290

BTW this method of getting the child status looses high 24bits of it.

kevans added inline comments.
usr.bin/lockf/lockf.c
290

To make sure I understand: this is waitpid vs. collecting from a waitpid() siginfo, right? Since we have dedicated fields for signal and exit status rather than compressing it all into a single 32-bit value?

usr.bin/lockf/lockf.c
290

that second one is apparently autocorrect from waitid, of course

usr.bin/lockf/lockf.c
290

Yes

usr.bin/lockf/lockf.c
104

this line should be lower (sort by size then by name)

365
kevans marked 4 inline comments as done.

Address review feedback; waitpid -> waitid will happen in a near-future change,
following ATF changes in D51034 and D51035 to allow me to test exit status
preservation above 8-bits.

Actually push all of the review feedback

Local changes had moved part of the signal setup earlier to avoid potentially
losing the new child in the process, but they apparently got stashed rather than
folded in. Added a note that we should just switch to a signal pipe if we add
any more complexity that we need to unwind in the child.

kib added inline comments.
usr.bin/lockf/lockf.c
255

I do not think it serves any purpose to reset the disposition of SIGCHLD in the child. It is set to handle, so execve resets SIGCHLD to default.

This revision is now accepted and ready to land.Thu, Jun 26, 4:41 AM

approved modulo @kib's comment