6 #include <msp/io/print.h>
12 string run_command(const StringList &argv, int *status)
22 char *argv_[argv.size()+1];
25 for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
26 argv_[j++] = strdup(i->c_str());
32 int devnull = open("/dev/null", O_WRONLY);
36 execvp(argv_[0], argv_);
40 IO::print(IO::cerr, "Failed to execute %s\n", argv.front());
47 int len = read(pfd[0], buf, sizeof(buf));
51 if(waitpid(pid, &s, WNOHANG))
56 *status = WEXITSTATUS(s);
64 result.append(buf, len);