diff --git a/uppsrc/ide/Console.cpp b/uppsrc/ide/Console.cpp index bf3a14972..44a750299 100644 --- a/uppsrc/ide/Console.cpp +++ b/uppsrc/ide/Console.cpp @@ -147,22 +147,28 @@ int Console::Flush() Slot& slot = processes[i]; if(!slot.process) continue; - String s; - slot.process->Read(s); - if(!IsNull(s)) { - done_output = true; - if(slot.outfile) - slot.outfile->Put(s); - if(!slot.quiet) { - if(console_lock < 0 || console_lock == i) { - console_lock = i; - AppendOutput(s); + auto Read = [&] { + String s; + slot.process->Read(s); + if(!IsNull(s)) { + done_output = true; + if(slot.outfile) + slot.outfile->Put(s); + if(!slot.quiet) { + if(console_lock < 0 || console_lock == i) { + console_lock = i; + AppendOutput(s); + } + else + slot.output.Cat(s); } - else - slot.output.Cat(s); + return true; } - } + return false; + }; + Read(); if(!slot.process->IsRunning()) { + while(Read()); Kill(i); if(slot.exitcode != 0 && verbosebuild) spooled_output.Cat("Error executing " + slot.cmdline + "\n"); @@ -179,10 +185,12 @@ int Console::Flush() int Console::Execute(One pick_ p, const char *command, Stream *out, bool q) { + DLOG("Execute " << command); Wait(); if(!Run(pick(p), command, out, q, 0)) return -1; Wait(); + Flush(); return processes[0].exitcode; }