Waiting for the process to finish first may lead to a deadlock if it
produces more output than can fit in the pipe's buffers.
Task::Status ExternalTask::do_wait(bool block)
{
Task::Status ExternalTask::do_wait(bool block)
{
- if(process->wait(block))
+ if(process->wait(!capture_pipe))
{
exit_code = process->get_exit_code();
delete process;
{
exit_code = process->get_exit_code();
delete process;
}
// Do this after waiting to avoid a race condition
}
// 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));
{
char buf[1024];
unsigned len = capture_pipe->read(buf, sizeof(buf));
+ {
+ if(!block)
+ return RUNNING;
+ }
else
signal_finished.emit(!exit_code);
}
else
signal_finished.emit(!exit_code);
}