I having a endless loop when in try to read from a ChildProcess which generates no output
int read (void* dest, int numNeeded) const
{
int total = 0;
while (ok && numNeeded > 0)
{
DWORD available = 0;
if (! PeekNamedPipe ((HANDLE) readPipe, nullptr, 0, nullptr, &available, nullptr))
break;
const int numToDo = jmin ((int) available, numNeeded);
if (available == 0)
{
// if (! isRunning()) !!!!!!!!!!!!! if nothing is available it should always break
break;
Thread::yield();
}
this function is used by ChildProcess::readProcessOutput, which gives the number of bytes back which were read, and i interpret “will attempt to read” as something non-blocking… , which gives 0 back when there is nothing to read…
but anyway we need something non-blocking…
/** Attempts to read some output from the child process.
This will attempt to read up to the given number of bytes of data from the
process. It returns the number of bytes that were actually read.
*/
I have a better version that uses non blocking reads and can digest tons of messages generated by the child log (try feeding a compiler or cmake as child process, juce will start buffering and the log will stutter) plus also proper environment control for the children.
Of course it has been ignored by the juce team, so i didn’t even try to spend 5 minutes to push an updated version in github