c++ - ConPTY 读取管道是否会在进程终止时收到通知?
问题描述
因此,我正在从连接到 PseudoConsole (ConPTY) 的管道中读取数据,当进程完成时,我想停止。在linux中,我们遇到了EOF
这种情况,但是在win32中,据我所知,我们没有得到任何指示。
但是解决方法是什么?
- 由于同步问题,检查进程是否仍然有效。
github上的类似问题https://github.com/microsoft/terminal/issues/329
问题的伪代码
fn main() {
let proc = conpty::spawn("ping").unwrap();
let mut reader = proc.output().unwrap();
loop {
let mut buf = [0; 1028];
// We will block here eventually.
// But how to not BLOCK when process is gone
let n = reader.read(&mut buf).unwrap();
}
}
谢谢你。
解决方案
推荐阅读
- wordpress - WooCommerce 中特定付款方式的自定义类结帐提交按钮文本
- go - 如何从`workflow.Context`中获取`context.Context`?
- html - 创建在亮模式下显示为黑色和在暗模式下显示为亮的 SVG
- javascript - 在 Safari 中使用表格滚动边距顶部?
- sql - 计算和连接多个表
- scala - 数据框中列的字数
- javascript - 如何从我的列表中随机分配 4 个文本框文本?并且其中一个与变量随机匹配?
- java - 菜单项未显示在工具栏中
- graph - 如何同时为 Manim 中的所有图形点设置动画?
- r - R:填充列直到结束并从头继续