Repository navigation
stdbuf: fix stdio getters in libstdbuf - #15480
Conversation
__stdbuf_get_stderr read _stdin from the reent struct on cygwin, so stdbuf -e changed the buffering of stdin instead of stderr. Introduced in 54ba74b ("Add more Cygwin support", uutils#9686).
There was a problem hiding this comment.
🟡 Changes recommended
The bug fix lacks the regression test required by repository guidelines.
1 open issue
What changed in this PR
Fixes Cygwin’s stderr getter so stdbuf -e changes stderr buffering rather than stdin buffering.
Changes:
- Returns
_stderrinstead of_stdinfrom the Cygwin reentrancy structure.
| File | Description |
|---|---|
| src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs | Corrects the Cygwin stderr stream pointer. |
Review effort: Balanced
Whoops, it looks like I forgot to replace this one when copy pasting... apologies :( |
Check that the stdin, stdout and stderr getters give file descriptors 0, 1 and 2. This would have caught the cygwin stderr getter returning stdin. Enable the unit tests of libstdbuf for this.
No problem. I just thought you may want to cherry-pick this if you have a use-case where you're using stdbuf on cygwin. |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
Review effort: Lite
|
Seems that the mac CI is sad |
__stdinp, __stdoutp and __stderrp are data variables, not functions. Calling them jumped into data and crashed with SIGBUS on macOS.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
Withtest = falseremoved,cargo testwill now attempt to build this crate’s unit tests. A… · New Removingtest = falseenables unit tests, but the crate is still configured as `crate-type =… The PR description focuses on the Cygwin_stdinvs_stderrbug, but this PR also changes the… · New This test hard-codes thatfileno(stdin/stdout/stderr)must be exactly0/1/2. While that’s… · New Add Cygwin regression test for stderr file descriptor getter
Review effort: Lite
| assert_eq!(fileno(__stdbuf_get_stdin()), 0); | ||
| assert_eq!(fileno(__stdbuf_get_stdout()), 1); | ||
| assert_eq!(fileno(__stdbuf_get_stderr()), 2); |
There was a problem hiding this comment.
could also use constants like: libc::STDIN_FILENO
There was a problem hiding this comment.
OK. I added a commit using the libc constants.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
Withtest = falseremoved,cargo testwill now attempt to build this crate’s unit tests. A… Removingtest = falseenables unit tests, but the crate is still configured as `crate-type =… This test hard-codes thatfileno(stdin/stdout/stderr)must be exactly0/1/2. While that’s… The PR description focuses on the Cygwin_stdinvs_stderrbug, but this PR also changes the… Add Cygwin regression test for stderr file descriptor getter
Review effort: Lite
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
7 open issues
With[lib] crate-type = [\"cdylib\"], Rust unit tests often fail to link because the test harness… · New Withtest = falseremoved,cargo testwill now attempt to build this crate’s unit tests. A… Removingtest = falseenables unit tests, but the crate is still configured as `crate-type =… These FFI bindings are read-only in this code path, but they are declared asstatic mut, which… · New This test hard-codes thatfileno(stdin/stdout/stderr)must be exactly0/1/2. While that’s… The PR description focuses on the Cygwin_stdinvs_stderrbug, but this PR also changes the… Add Cygwin regression test for stderr file descriptor getter
Review effort: Lite
| [lib] | ||
| name = "stdbuf" | ||
| path = "src/libstdbuf.rs" | ||
| crate-type = ["cdylib"] |
| static mut __stdinp: *mut FILE; | ||
| } | ||
| unsafe { __stdinp() } | ||
| unsafe { __stdinp } |
There was a problem hiding this comment.
🔵 Needs a closer look
No defects were identified, but affected-platform CI results remain unverified for these foreign-function interface fixes.
3 open issues
4 resolved since last review
Withtest = falseremoved,cargo testwill now attempt to build this crate’s unit tests. A… Removingtest = falseenables unit tests, but the crate is still configured as `crate-type =… The PR description focuses on the Cygwin_stdinvs_stderrbug, but this PR also changes the… Add Cygwin regression test for stderr file descriptor getter
Review effort: Balanced
The Mac CI is fixed now. |
|
Thanks for your PR |



The new unit test checks that each getter returns its own stream (fd 0, 1, 2).