X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmisc.cpp;h=2409e05a650a7fb5c67885d799f9359ad550037b;hb=4629d189a531c962cf15a511df787f30c3adcb02;hp=a299f0e54b6f1f36c05d338d8c5397eef36495e8;hpb=bdc8b6638b486aa668b4a9c6c5cce5f6b5f18222;p=builder.git diff --git a/source/misc.cpp b/source/misc.cpp index a299f0e..2409e05 100644 --- a/source/misc.cpp +++ b/source/misc.cpp @@ -1,24 +1,21 @@ /* $Id$ This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include #include +#include #include #include +#include #include "misc.h" using namespace std; using namespace Msp; -/** -Runs a command and returns its output as a string. The exit status of the -command is lost. -*/ -string run_command(const StringList &argv) +string run_command(const StringList &argv, int *status) { int pfd[2]; pipe(pfd); @@ -37,13 +34,16 @@ string run_command(const StringList &argv) close(pfd[0]); dup2(pfd[1], 1); - dup2(pfd[1], 2); + close(pfd[1]); + int devnull=open("/dev/null", O_WRONLY); + dup2(devnull, 2); + close(devnull); execvp(argv_[0], argv_); ::exit(1); } else if(pid==-1) - cerr<<"Failed to execute "<