Fix program hang by closing pipe in the parent process#552
Closed
CHN-beta wants to merge 1 commit intoboostorg:developfrom
Closed
Fix program hang by closing pipe in the parent process#552CHN-beta wants to merge 1 commit intoboostorg:developfrom
CHN-beta wants to merge 1 commit intoboostorg:developfrom
Conversation
2ba5cec to
2131c08
Compare
2131c08 to
efe34a1
Compare
Collaborator
|
This might be a bug with auto proc = bp::process
(context, actual_program, { "hhh" }, bp::process_stdio{ .in = {}, .out = *stdout_pipe, .err = {} }, std::move(env));Otherwise, this change is just wrong, because you're just closing everything. You can open an issue if the above doesn't work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this patch, pipe file descriptors were not properly closed after
forkwas called. This causes the program to hang infinitely under specific conditions.The following code could be used to reproduce the issue:
Compile the code with pidfd disabled (either by setting the
BOOST_PROCESS_V2_DISABLE_PIDFD_OPENmacro or by using an old kernel header like 3.10), the program will hang after starting.stracegives:As shown in the strace output, the child process successfully exits, but the parent process blocks indefinitely on read(6). The root cause is that the writing-end of the pipe (fd 7) is still open in the parent process, even it has been closed in the child process (since the child process have died) and should never be used in the parent process. This make the read operation on reading-end of the pipe (fd 6) remains blocked waiting for EOF.