ChildProcess issues on macOS 10.12.6

On individual installations of 10.12.6 only, there seem to be transient issues with readAllProcessOutput() that haven’t occurred on earlier versions of macOS. In the code snippet below, output would occasionally be empty, despite the child process writing to stdout.

ChildProcess spawn;
if (spawn.start (commandTokens, wantStdOut | wantStdErr))
    String output = spawn.readAllProcessOutput();
    int error = spawn.getExitCode();

Users consistently reported this on that version of macOS only, although I could not reproduce it yet. Seems to depend on hardware (speed) or system components.

Passing output through an external file instead however fixed it, which makes me believe the pipe might have become unstable for some reason.

Has anyone else observed this?

Would adding a delay before readAllProcessOutput() possibly help by allowing the pipe some time to establish?

And, as we are at it, I’d like to suggest putting a small delay into the loop of ChildProcess::waitForProcessToFinish, as otherwise it does excessive pollling at an insane rate.

I now ditched the pipe and went with an external file, as I could not get it working no matter what.

I’m using this for a plugin scanner that spawns a child process for each plugin found and reports back what’s in the plugin. I really wonder how others implemented this, as the pipe doesn’t seem to be reliable.

I’m also have some weird behaviour, Its like childProcess has stopped working, it seams it is simply not executing anything.

Please see this post and see if it fixes the issue for you.