X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fexternaltask.cpp;h=dce0e06d6157700db2efab0ca32a27d5ba26aceb;hb=3a61505c629d51f52343e7dfaaa936143557c3bf;hp=e4dfdc2ef9566122042d6ad430595acb1488f6b0;hpb=2d9a6cf1b0123e5962d5558b57f74c1faf33bf0b;p=builder.git diff --git a/source/externaltask.cpp b/source/externaltask.cpp index e4dfdc2..dce0e06 100644 --- a/source/externaltask.cpp +++ b/source/externaltask.cpp @@ -1,11 +1,10 @@ #include #include -#include #include #include #include #include -#include +#include #include "externaltask.h" using namespace std; @@ -73,7 +72,11 @@ void ExternalTask::start() if(stdin_action==IGNORE || stdout_action==IGNORE || stderr_action==IGNORE) { +#ifdef _WIN32 + devnull = new IO::File("nul", IO::M_RDWR); +#else devnull = new IO::File("/dev/null", IO::M_RDWR); +#endif if(stdin_action==IGNORE) process->redirect_cin(*devnull); if(stdout_action==IGNORE) @@ -128,9 +131,9 @@ Task::Status ExternalTask::wait() Task::Status ExternalTask::do_wait(bool block) { - if(process) + while(process) { - if(process->wait(block)) + if(process->wait(block && !capture_pipe)) { exit_code = process->get_exit_code(); delete process; @@ -138,7 +141,7 @@ Task::Status ExternalTask::do_wait(bool block) } // Do this after waiting to avoid a race condition - while(capture_pipe && IO::poll(*capture_pipe, IO::P_INPUT, Time::zero)) + while(capture_pipe && IO::poll(*capture_pipe, IO::P_INPUT, 10*Time::msec)) { char buf[1024]; unsigned len = capture_pipe->read(buf, sizeof(buf)); @@ -149,7 +152,10 @@ Task::Status ExternalTask::do_wait(bool block) } if(process) - return RUNNING; + { + if(!block) + return RUNNING; + } else signal_finished.emit(!exit_code); }