class ChildProcess::ActiveProcess::read endless Loop (win32)



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))

            const int numToDo = jmin ((int) available, numNeeded);

            if (available == 0)
              //  if (! isRunning())      !!!!!!!!!!!!! if nothing is available it should always break



Well, the code does exactly what it’s supposed to do - it’s waiting for your process to either generate some output, or to exit.

If you want a non-blocking read function, that’d be a feature request, but the current one is designed to block.


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… :smiley:

/** 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. */


Yeah, sorry - that comment wasn’t very clear! The method should probably have a time-out parameter added to it.