Conversation
When stdin/out/err are closed on tool start, checkfds() tries to fill them by invoking `pipe()` which is may allocate file descriptors in an unwanted order and may create a pipe between stdout and stdin which is not what we want. Use 'nul' on Windows or '/dev/null' if HAVE_PIPE is defined to open the closed descriptors. Caveat: I am not 100% sure that HAVE_PIPE implies that /dev/null works, but it seems likely?
There was a problem hiding this comment.
Pull request overview
Updates startup descriptor recovery to use the platform null device instead of pipes.
Changes:
- Opens closed stdin, stdout, and stderr on
nulor/dev/null. - Keeps descriptor direction appropriate for input and output.
Suppressed comments (1)
src/tool_main.c:90
- DOS builds also use the
NULdevice, but this guard sendsMSDOSbuilds to/dev/null. The existing platform handling intests/libtest/lib518.c:33-36andtests/libtest/lib537.c:30-34includes both_WIN32andMSDOS; without the same check here, supported DOS builds withHAVE_PIPEandHAVE_FCNTLfail startup when a standard descriptor is closed.
#ifdef _WIN32
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
icing
marked this pull request as ready for review
August 28, 2026 12:01
Member
Right, but otherwise it fails anyway so it seems that if it against all odds actually causes trouble for someone we should hear about it... |
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.
When stdin/out/err are closed on tool start, checkfds() tries to fill them by invoking
pipe()which is may allocate file descriptors in an unwanted order and may create a pipe between stdout and stdin which is not what we want.Use 'nul' on Windows or '/dev/null' if HAVE_PIPE is defined to open the closed descriptors.
Caveat: I am not 100% sure that HAVE_PIPE implies that /dev/null works, but it seems likely?