X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmisc.cpp;h=a299f0e54b6f1f36c05d338d8c5397eef36495e8;hb=bdc8b6638b486aa668b4a9c6c5cce5f6b5f18222;hp=35953a74efb00b4a1ad1e1979469eecd74427c72;hpb=74266a6e650f019063cdcd1c9a7bd26d8f99041b;p=builder.git diff --git a/source/misc.cpp b/source/misc.cpp index 35953a7..a299f0e 100644 --- a/source/misc.cpp +++ b/source/misc.cpp @@ -1,6 +1,14 @@ +/* $Id$ + +This file is part of builder +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include -#include +#include +#include #include "misc.h" using namespace std; @@ -21,12 +29,16 @@ string run_command(const StringList &argv) if(pid==0) { char *argv_[argv.size()+1]; - for(CountingIterator i=argv.begin(); i!=argv.end(); ++i) - argv_[i.count()]=strdup(i->c_str()); - argv_[argv.size()]=0; + + unsigned j=0; + for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i) + argv_[j++]=strdup(i->c_str()); + argv_[j]=0; + close(pfd[0]); dup2(pfd[1], 1); dup2(pfd[1], 2); + execvp(argv_[0], argv_); ::exit(1); } @@ -48,7 +60,7 @@ string run_command(const StringList &argv) result.append(buf, len); } } - + return result; }