Skip to content

fix(utils): close the parent ends in PipeSet::closeParentEnds - #2122

Open
chennaji9 wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/pipeset-close-parent-ends
Open

chennaji9 wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/pipeset-close-parent-ends

Conversation

@chennaji9

Copy link
Copy Markdown

What does this PR do?

PipeSet splits the six pipe descriptors between parent and child (per setupChildStdio()): the child owns the stdin READ end and the stdout/stderr WRITE ends; the parent owns the stdin WRITE end and the stdout/stderr READ ends.

closeChildEnds() closed the correct three descriptors, but closeParentEnds() was an exact copy of it — it closed the child-facing ends again and never closed the ends the parent actually owns. A parent calling it after fork() leaked its own pipe ends.

Two commits:

  1. fix(utils): make closeParentEnds() close the parent-owned ends (stdin write end, stdout/stderr read ends).
  2. fix(cli): the only caller, the non-tty parent branch of Cli::reuseContainer, called closeParentEnds() while actually needing to drop the parent's copies of the child-facing ends — switch it to closeChildEnds(). (It worked before only because the old closeParentEnds() body was wrong in exactly that way.) The parent then adopts the parent-owned ends via releaseWriteEnd()/releaseReadEnd() for the epoll forwarding loop, unchanged.

Validation

  • New unit test PipeSet.CloseParentEndsKeepsChildEndsOpen: after closeParentEnds(), fcntl(F_GETFD) confirms the child-facing ends are still open while the parent-facing ends are closed.
  • Full test suite on this branch: ctest -j4 → 737/737 passed (includes all existing Cli/utils tests — no regressions from the reuseContainer change).
  • Full project build passes.

🤖 Generated with Claude Code

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @chennaji9. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/linglong/src/linglong/cli/cli.cpp 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
libs/utils/src/linglong/utils/io/pipe.h 40.74% <100.00%> (+2.44%) ⬆️
libs/linglong/src/linglong/cli/cli.cpp 5.07% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

closeParentEnds() closed the same descriptors as closeChildEnds(),
leaking the parent-owned pipe ends after fork; close the stdin write
end and the stdout/stderr read ends, which are the ends the parent
owns per setupChildStdio(); add a unit test.

Signed-off-by: 陈那几 <2078634206@qq.com>
the non-tty parent branch called closeParentEnds(), which used to
(incorrectly) close the child-facing ends; now that closeParentEnds()
actually closes the parent ends, the parent must call closeChildEnds()
to drop its copies of the child-facing descriptors before adopting the
parent ends for the forwarding loop.

Signed-off-by: 陈那几 <2078634206@qq.com>
@chennaji9
chennaji9 force-pushed the fix/pipeset-close-parent-ends branch from d4abd73 to 5bf5399 Compare October 13, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants