5 #include <msp/io/print.h>
11 string run_command(const StringList &argv, int *status)
21 char *argv_[argv.size()+1];
24 for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
25 argv_[j++] = strdup(i->c_str());
31 int devnull = open("/dev/null", O_WRONLY);
35 execvp(argv_[0], argv_);
39 IO::print(IO::cerr, "Failed to execute %s\n", argv.front());
46 int len = read(pfd[0], buf, sizeof(buf));
50 if(waitpid(pid, &s, WNOHANG))
55 *status = WEXITSTATUS(s);
63 result.append(buf, len);