C ++ proc_open模拟 [英] C++ proc_open analogue
问题描述
PHP中有一个方便的函数,称为 proc_open
.它可以用来调用可执行文件,将其stdin
,stdout
和stderr
作为管道打开.
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).
推荐答案
您可能会在某处"获得
-
popen
( http://linux.die.net/man/3/popen )
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++
-
Poco :: Process
launch
( http: //www.appinf.com/docs/poco/Poco.Process.html#13423 )
static ProcessHandle launch(
const std::string & command,
const Args & args,
Pipe * inPipe,
Pipe * outPipe,
Pipe * errPipe
);
这篇关于C ++ proc_open模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!