Page MenuHomeFreeBSD

lockf: don't hold stdin/stdout/stderr open
ClosedPublic

Authored by kevans on Nov 22 2023, 5:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 6:04 AM
Unknown Object (File)
Thu, May 9, 12:52 AM
Unknown Object (File)
Tue, May 7, 6:28 AM
Unknown Object (File)
Sat, May 4, 1:16 PM
Unknown Object (File)
Sun, Apr 28, 10:10 AM
Unknown Object (File)
Fri, Apr 26, 2:21 AM
Unknown Object (File)
Apr 14 2024, 7:40 PM
Unknown Object (File)
Apr 14 2024, 5:34 PM

Details

Summary

None of these are essential in the lockf monitor (parent post-fork), so
close them to maintain the illusion that lockf hasn't been inserted into
the pipeline. This ensures that the correct effects happen on other
programs in the pipeline if the locked command closes or redirects these
elsewhere.

The original patch used -s to close stdout/stderr rather than closing
them unconditionally, but it's not clear that we really care that much.

PR: 112379
Sponsored by: Klara, Inc.

Diff Detail

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

Event Timeline

0mp added a subscriber: 0mp.

It seems like the commit message should contain "Reported by". The reference to "the original patch" is a bit unclear as well. It took me a moment to figure out that this is pointing at the patch from the PR.

Perhaps the commit message could contain the example from the Bugzilla PR, i.e., (script1.sh | lockf foo script2.sh 2>&1 &) | mail -s something somewhere.

usr.bin/lockf/lockf.c
164

Didn't the old err contain more details?

This revision is now accepted and ready to land.Nov 22 2023, 10:35 AM
allanjude added a subscriber: allanjude.

reviewed-by: allanjude

des added inline comments.
usr.bin/lockf/lockf.c
164

sure but there is no stderr at this point.

des requested changes to this revision.Nov 22 2023, 2:39 PM
des added inline comments.
usr.bin/lockf/lockf.c
216

stderr is almost certainly closed at this point.

This revision now requires changes to proceed.Nov 22 2023, 2:39 PM
kevans marked 3 inline comments as done.

stderr will almost always be closed when killed is called, so just exit.

usr.bin/lockf/lockf.c
164

I note that there's very little failure mode left with waitpid() anyways when used in this manner, so I wasn't too concerned about working out some gymnastics to try and make it more debuggable looking.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 26 2023, 4:12 AM
This revision was automatically updated to reflect the committed changes.