3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
16 Runs a command and returns its output as a string. The exit status of the
19 string run_command(const StringList &argv)
29 char *argv_[argv.size()+1];
32 for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
33 argv_[j++]=strdup(i->c_str());
40 execvp(argv_[0], argv_);
44 cerr<<"Failed to execute "<<argv.front()<<'\n';
51 int len=read(pfd[0], buf, sizeof(buf));
54 if(waitpid(pid, 0, WNOHANG))
58 result.append(buf, len);