X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexternalaction.cpp;h=bde453f8c18b7321d0835ad54ce3913f93e0dfce;hb=7aeaa4ba965f596edad438c02e345a8843f7469a;hp=7f9e974ebd64ba398424545aeaddb844a5a7ab04;hpb=f1c967215e6b08095bdf07518472beca3067ec37;p=builder.git diff --git a/source/externalaction.cpp b/source/externalaction.cpp index 7f9e974..bde453f 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -1,5 +1,12 @@ +/* $Id$ + +This file is part of builder +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include -#include +#include #include "builder.h" #include "externalaction.h" @@ -13,9 +20,9 @@ int ExternalAction::check() signal_done.emit(); return 0; } - + if(!pid) - return 255; + return exit_code; int status; if(waitpid(pid, &status, WNOHANG)==pid) @@ -25,17 +32,21 @@ int ExternalAction::check() exit_code=WEXITSTATUS(status); else exit_code=254; + pid=0; return exit_code; } else return -1; } +/** +Starts the external program. Fill in argv before calling this. +*/ void ExternalAction::launch() { if(builder.get_verbose()>=2) { - for(list::const_iterator i=argv.begin(); i!=argv.end(); ++i) + for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i) { if(i!=argv.begin()) cout<<' '; @@ -43,7 +54,7 @@ void ExternalAction::launch() } cout<<'\n'; } - + if(builder.get_dry_run()) pid=-1; else @@ -52,10 +63,14 @@ void ExternalAction::launch() if(pid==0) { char *argv_[argv.size()+1]; - for(CountingIterator::iterator> i=argv.begin(); i!=argv.end(); ++i) - argv_[i.count()]=strdup(i->c_str()); - argv_[argv.size()]=0; + + unsigned j=0; + for(StringList::iterator i=argv.begin(); i!=argv.end(); ++i) + argv_[j++]=strdup(i->c_str()); + argv_[j]=0; + execvp(argv_[0], argv_); + cout<<"Couldn't execute "<