[0141] 修复 Windows 平台 subprocess 管道捕获失败问题 - #962
Merged
Merged
Conversation
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.
[0141] 修复 Windows 平台 subprocess 管道捕获导致 gf pr / run-values 失败的问题
任务相关的代码文件
如何测试
2026-08-31 修复 Windows 下 subprocess 管道捕获
What
(liii subprocess)在执行管道重定向(:stdout 'capture、:stderr 'capture、:input、run-pipe)时无法正确捕获输出甚至报错的问题。gf pr在 Windows 下因pr-remote-url无法捕获 git 输出而误报Error: no origin remote found in this repository的问题。run-values-test.scm和run-pipe-test.scm的捕获与管道断言测试。Why
在 Windows 平台上,tbox 的
tb_pipe_file_init_pair内部通过带有FILE_FLAG_OVERLAPPED标志的具名管道实现异步 I/O。当子进程(如 Git、Python 或标准 C 运行时程序)继承该句柄并使用同步WriteFile写入时,Windows API 会返回ERROR_INVALID_PARAMETER(Errno 22),导致写入失败、输出捕获为空字符串。How
_WIN32)下,使用原生 Win32 APICreatePipe创建同步管道,句柄传递给子进程的attr.out.file/attr.err.file/attr.in.file并标记继承。ReadFile循环读取子进程管道输出直至 EOF,正确填充stdout_str/stderr_str。tests/liii/subprocess/run-values-test.scm与run-pipe-test.scm,加入 Windows 平台的管道捕获与串联管道验证。