I have a JUCE gui based app which I have converted to console app (by adding _CONSOLE #define, a main.cpp and not launching the gui thread). This works fine, and I can use command line parameters, and print output to the console (cmd.exe or powershell) using the typical std::cout.
However, this console app is to be used as endpoints by php script and I’ve run into a couple issues, including perhaps my own confusion about how to direct the output to the calling php/thread/endpoint.
The first instance of the app directs the output to std::cout fine. When the same exe is called from command line with another command, I can step into anotherInstanceStarted as expected, but of course the new instance exits almost immediately as the new command/thread is started in the main process loop, and as such all output for this new ‘session’ is redirected to the main instance std::cout. Is there a way in JUCE to grab the handle of subsequent calling instance to redirect output to the proper endpoint?
In an effort to work around the above issue, I’ve attempted to implement ChildProcess class for all subsequent commands to the main.exe, again via anotherInstanceStarted. But again while the childProcess starts up fine, I am unable to read the output let alone redirect it to caller. In this case, regardless of whether I call readProcessOutput or readAllProcessOutput, those calls are blocking calls and do not return until the childProcess ends… the whole point of reading the output via a thread/loop is to get status/progress from the child process while it’s running. I’m about to try ChildProcessMaster/Slave implementations in hopes they’re more robust, but I have a suspicion this still won’t solve the issue of redirecting the std::cout to the corresponding handle.