3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
19 Runs a command and returns its output as a string. The exit status of the
22 string run_command(const StringList &argv)
32 char *argv_[argv.size()+1];
35 for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
36 argv_[j++]=strdup(i->c_str());
42 int devnull=open("/dev/null", O_WRONLY);
46 execvp(argv_[0], argv_);
50 cerr<<"Failed to execute "<<argv.front()<<'\n';
57 int len=read(pfd[0], buf, sizeof(buf));
60 if(waitpid(pid, 0, WNOHANG))
64 result.append(buf, len);