X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexternaltask.cpp;h=e4dfdc2ef9566122042d6ad430595acb1488f6b0;hb=HEAD;hp=24716662804528fcdae50421511379fd576b6d57;hpb=338eefb513953ae55e8e3614c009c242ba8ad74e;p=builder.git diff --git a/source/externaltask.cpp b/source/externaltask.cpp deleted file mode 100644 index 2471666..0000000 --- a/source/externaltask.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include -#include "externaltask.h" - -using namespace std; -using namespace Msp; - -ExternalTask::ExternalTask(const vector &argv, const FS::Path &work_dir): - pid(-1), - exit_code(-1) -{ - if((pid = fork())) - { - if(pid==-1) - exit_code = 1; - else - exit_code = 0; - } - else - { - vector cargv(argv.size()+1); - for(unsigned i=0; i(&cargv.front())); - IO::print("Couldn't execute %s\n", argv.front()); - exit(1); - } -} - -Task::Status ExternalTask::check() -{ - if(pid>0) - { - int status; - if(waitpid(pid, &status, WNOHANG)==pid) - { - if(WIFEXITED(status)) - exit_code = WEXITSTATUS(status); - else if(WIFSIGNALED(status)) - exit_code = 256+WTERMSIG(status); - else - exit_code = 1025; - pid = 0; - - signal_finished.emit(!exit_code); - } - else - return RUNNING; - } - - return exit_code ? ERROR : SUCCESS; -}