3 This file is part of builder
4 Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
12 #include <msp/io/print.h>
18 string run_command(const StringList &argv, int *status)
28 char *argv_[argv.size()+1];
31 for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
32 argv_[j++] = strdup(i->c_str());
38 int devnull = open("/dev/null", O_WRONLY);
42 execvp(argv_[0], argv_);
46 IO::print(IO::cerr, "Failed to execute %s\n", argv.front());
53 int len = read(pfd[0], buf, sizeof(buf));
57 if(waitpid(pid, &s, WNOHANG))
62 *status = WEXITSTATUS(s);
70 result.append(buf, len);