Repository navigation
Conversation
…et buffer cligen_output wrote the whole command output to the pipe socketpair with a blocking write(), and only read the pipe command (eg grep) output after the command output was complete. If the pipe command produced more output than fits in the socket buffer it blocked writing, stopped reading its input, and both sides waited for each other forever. Write with select/send and drain the pipe command output to stdout while the socket is not writable.
test_pipe.sh: pipe command output (~1MB) larger than the socket buffer must not deadlock with the writer.
pexaxep
force-pushed
the
fix/pipe-output-deadlock
branch
from
October 19, 2026 16:47
61794cf to
fda2f90
Compare
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.
cmd | grep ...(any output pipe) hangs forever when the output of the pipe command is larger than the socket buffer (~200 KB with defaultnet.core.wmem_default).cligen_output()writes the whole command output to the pipe socketpair with a blockingwrite(), and the output of the pipe command (eg grep) is only read afterwards incligen_eval_pipe_post(). If the pipe command produces more output than the socket buffer holds, it blocks inwrite()and stops reading its input. The input buffer then fills up andcligen_output()blocks as well: both sides wait for each other. Increasing the socket buffer only moves the threshold.The fix writes to the pipe socket via a new
pipe_socket_write()usingselect()andsend(MSG_DONTWAIT | MSG_NOSIGNAL), and reads the pipe command output to stdout while the socket is not writable. The behaviour for small outputs is unchanged, andEPIPEwhen the pipe command closes its side is handled as before.cligen_eval_pipe_pre()andcligen_eval_pipe_post()are not modified.Regression tests added to test_pipe.sh (
big | grep abcandbig | cat, ~1 MB of pipe command output). Without the fix the command hangs (the test times out), with the fix test_pipe.sh passes.