10 Runs a command and returns its output as a string. The exit status of the
13 string run_command(const StringList &argv)
23 char *argv_[argv.size()+1];
24 for(CountingIterator<const string, StringList::const_iterator> i=argv.begin(); i!=argv.end(); ++i)
25 argv_[i.count()]=strdup(i->c_str());
30 execvp(argv_[0], argv_);
34 cerr<<"Failed to execute "<<argv.front()<<'\n';
41 int len=read(pfd[0], buf, sizeof(buf));
44 if(waitpid(pid, 0, WNOHANG))
48 result.append(buf, len);