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
F102786276: D42713.diff
Sun, Nov 17, 4:31 AM
Unknown Object (File)
Thu, Nov 14, 2:13 PM
Unknown Object (File)
Sun, Nov 10, 7:35 AM
Unknown Object (File)
Sat, Nov 9, 10:56 PM
Unknown Object (File)
Sat, Nov 2, 4:18 AM
Unknown Object (File)
Sep 24 2024, 8:15 AM
Unknown Object (File)
Sep 20 2024, 8:55 AM
Unknown Object (File)
Sep 19 2024, 8:36 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 54561
Build 51450: arc lint + arc unit

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.