gpt4 book ai didi

go - 为什么 os/exec.StderrPipe 的编写器在 Start() 中关闭?

转载 作者:数据小太阳 更新时间:2023-10-29 03:21:53 24 4
gpt4 key购买 nike

谁能帮我理解为什么pw (the writer)计划于 Start() 结束?

我希望 pwpr ( the reader) 一起关闭在 Wait() .

最佳答案

closeAfterStartcloseAfterwaitio.Closers 的两片分别称为 ins StartWaitcmd结构。现在,这是为什么?这两个基本上都是缓冲区( slice ),需要写入读出。根据它们当前是否正在使用,它们将被关闭。例如 StdInPipe需要先读取再写入,因此 pr包含在 closeAfterStart 中和 pwcloseAfterWait .对 StdOutPipe 执行相反的操作.

该程序只是关闭代码中不再需要的缓冲区。在 StdErrPipe该函数在执行命令后调用,将错误输出写入某些输出。所以,程序已经有了它需要编写的输出。

关于go - 为什么 os/exec.StderrPipe 的编写器在 Start() 中关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52529255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com