I spot a nasty issue in posix ActiveProcess::isRunning
if called in a loop together with readProcessOutput. because the childState int is not initialised to 0, the second call to waitpid will return strange values and i end up with random exit status all the time.
bool isRunning() noexcept
{
if (childPID == 0)
return false;
int childState = 0; // <<<<<<<<<<<< INIT TO ZERO !
auto pid = waitpid (childPID, &childState, WNOHANG);
if (pid == 0)
return true;
if (WIFEXITED (childState))
{
exitCode = WEXITSTATUS (childState);
return false;
}
return ! WIFSIGNALED (childState);
}
The loop where i discovered the issue is something on the line of this:
for (;;)
{
auto bytesRead = childProcess.readProcessOutput(buffer, bufferSize);
if (bytesRead <= 0 && ! childProcess.isRunning())
break;
textCallback(buffer, bytesRead);
}
Which works with unbuffered ::read (instead of juce fread).