X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexternalaction.cpp;h=97f6c619f426cb16e50cef20aa170e2008b86ea7;hb=2842eeda5aa7c143b3ff54d48f8673bbdcb35c75;hp=7f9e974ebd64ba398424545aeaddb844a5a7ab04;hpb=f1c967215e6b08095bdf07518472beca3067ec37;p=builder.git diff --git a/source/externalaction.cpp b/source/externalaction.cpp index 7f9e974..97f6c61 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "builder.h" #include "externalaction.h" @@ -15,7 +16,7 @@ int ExternalAction::check() } if(!pid) - return 255; + return exit_code; int status; if(waitpid(pid, &status, WNOHANG)==pid) @@ -25,17 +26,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<<' '; @@ -52,10 +57,11 @@ void ExternalAction::launch() if(pid==0) { char *argv_[argv.size()+1]; - for(CountingIterator::iterator> i=argv.begin(); i!=argv.end(); ++i) + for(CountingIterator i=argv.begin(); i!=argv.end(); ++i) argv_[i.count()]=strdup(i->c_str()); argv_[argv.size()]=0; execvp(argv_[0], argv_); + cout<<"Couldn't execute "<