相关疑难解决方法(0)

你将如何从Rust中的Process流输出?

这个问题是指2014年10月的Rust.

如果您使用的是Rust 1.0或更高版本,那么最好在别处寻找解决方案.


我有一个长时间运行的Rust进程,它生成日志值,我正在使用Process运行.

虽然我可能会定期"检查"正在运行的进程set_timeout()并使用wait()和执行某种高级循环,例如:

let mut child = match Command::new("thing").arg("...").spawn() {
    Ok(child) => child,
    Err(e) => fail!("failed to execute child: {}", e),
};
loop {
    child.set_timeout(Some(100));
    match child.wait() {
        // ??? Something goes here
    }
}
Run Code Online (Sandbox Code Playgroud)

我不是百分之百的事情是; 我如何区分超时错误和进程返回错误之间的区别wait(),以及如何使用PipeStream"尽可能多地读取而不阻塞流"每个推出间隔.

这是最好的方法吗?我应该开始监视stdout和stderr的任务吗?

rust rust-obsolete

1
推荐指数
1
解决办法
827
查看次数

标签 统计

rust ×1

rust-obsolete ×1