C ++ proc_open模拟 [英] C++ proc_open analogue

查看:98
本文介绍了C ++ proc_open模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP中有一个方便的函数,称为 proc_open .它可以用来调用可执行文件,将其stdinstdoutstderr作为管道打开.

There's a handy function in PHP called proc_open. It could be used to call an executable, opening its stdin, stdout and stderr as pipes.

在C ++中,此函数是否有一个很好的跨平台版本?唯一可以谷歌搜索的东西是 Windows教程(尽管其中的代码只是挂起).

Is there a good cross-platform version of this function in C++? The only googlable thing is this tutorial for Windows (though code from it just hangs).

推荐答案

您可能会在某处"获得

pstreams库(POSIX流程控制)-我对此没有经验它看起来很坚固,由乔纳森·韦克利(Jonathan Wakely)撰写

pstreams library (POSIX process control) - I have no prior experience with this, but it looks solid and was written by Jonathan Wakely

提升过程( http://www.highscore.de/boost/process/,尚未提升)

Boost Process (http://www.highscore.de/boost/process/, not in boost yet)

  • See also How to bind program termination with end-of-stream in Boost.Process 0.5?
  • and output with boost process library in c++
static ProcessHandle launch(
   const std::string & command,
    const Args & args,
    Pipe * inPipe,
    Pipe * outPipe,
    Pipe * errPipe
);

这篇关于C ++ proc_open模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆