Search code examples
asynchronousprocessipcd

Async Process Calls


What is the preferred way of calling other processes asynchronously in D? My use case is calling svn status checking exit status, and parsing its standard output and error.


Solution

  • I think std.stdio.popen is what you want:

    void popen(string command, in char[] stdioOpenmode = "r");
    

    Use it with a File and you get the output; something like:

    File f;
    f.popen("svn status", "r");
    char[] line;
    string result;
    while (f.readln(line))
        result ~= line;
    return result;
    

    Or you can use std.process.shell which apparently does this for you (and throws an ErrnoException on error).