ChildProcess readAllProcessOutput() returns empty String mac

Hi,

I use the following code to run a perl script from within my JUCE application

ChildProcess child;
if(child.start(processStr))
{
	const String result (child.readAllProcessOutput());
	child.waitForProcessToFinish (60 * 1000);
	return result;
}
else
{
	return "failed to start process";
}

On Linux this works and I get the result String with the output from the perl script. However on Mac the result String is empty.
The process runs fine but the output is missing.

I am running Mac OS 10.7.3 and Xcode 4.3.2.

Thanks,
Peter

Maybe It’s a timing issue and by the time you call readAllProcessOutput() your perl script had already released its output.

Yes, it could be a timing issue. The return String readAllProcessOutput() is always empty on Mac.

I changed the running a process code to

FILE* pipe = popen(processString, "r");
if (!pipe) return "ERROR";
char buffer[128];
String result = "";
while(!feof(pipe)) {
    if(fgets(buffer, 128, pipe) != NULL)
           result += buffer;
}
pclose(pipe);
return result;

and now I get the process output on both Mac and Linux.

It probably is some sort of timing issue, but I can’t see where it could be happening…