是否有一个在D中分叉和与子进程通信的例子?

fad*_*bee 4 fork d pipe popen

你如何在D中分叉和与子进程通信?

我想我几乎都在寻找http://erdani.com/d/new-stdio/phobos-prerelease/std_process.html#pipeProcess,但是pipeProcess似乎不在D2中.

我想执行一个子进程,并能够从其stdout和stderr读取,写入其stdin并接收退出通知及其退出代码.

在D中这样做的最佳方式是什么?

谢谢,

克里斯.

Jus*_*n W 5

最终这个功能将在Phobos中,但是现在,这是一个我扔在一起的类:Pastebin链接

你这样使用它:

auto stream = new ProcessStream("ls -a");
// read, write, etc. from stream
Run Code Online (Sandbox Code Playgroud)