1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00
This commit is contained in:
Léon 2025-12-24 08:17:15 -05:00 committed by GitHub
commit 2687d24062
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 5 deletions

View file

@ -166,13 +166,27 @@ bool ChildProcessCoordinator::sendMessageToWorker (const MemoryBlock& mb)
bool ChildProcessCoordinator::launchWorkerProcess (const File& executable, const String& commandLineUniqueID,
int timeoutMs, int streamFlags)
{
killWorkerProcess();
auto pipeName = "p" + String::toHexString (Random().nextInt64());
StringArray args;
args.add (executable.getFullPathName());
args.add (getCommandLinePrefix (commandLineUniqueID) + pipeName);
return launchWorkerProcess(args, commandLineUniqueID, timeoutMs, streamFlags);
}
bool ChildProcessCoordinator::launchWorkerProcess(const StringArray& arguments, const String& commandLineUniqueID,
int timeoutMs, int streamFlags)
{
killWorkerProcess();
auto pipeName = "p" + String::toHexString(Random().nextInt64());
StringArray args;
args.add(arguments[0]);
args.add(getCommandLinePrefix(commandLineUniqueID) + pipeName);
if (arguments.size() > 1)
{
args.addArray(arguments.begin() + 1, arguments.end());
}
childProcess = [&]() -> std::shared_ptr<ChildProcess>
{

View file

@ -186,6 +186,32 @@ public:
int timeoutMs = 0,
int streamFlags = ChildProcess::wantStdOut | ChildProcess::wantStdErr);
/** Attempts to launch and connect to a worker process by command line.
The first argument should be the name of the executable file, followed by any other
arguments that are needed.
This will start the given executable, passing it a special command-line
parameter as first argument based around the commandLineUniqueID string, which must be a
short alphanumeric string (no spaces!) that identifies your app. The exe
that gets launched must respond by calling ChildProcessWorker::initialiseFromCommandLine()
in its startup code, and must use a matching ID to commandLineUniqueID.
The timeoutMs parameter lets you specify how long the child process is allowed
to go without sending a ping before it is considered to have died and
handleConnectionLost() will be called. Passing <= 0 for this timeout makes
it use a default value.
If this all works, the method returns true, and you can begin sending and
receiving messages with the worker process.
If a child process is already running, this will call killWorkerProcess() and
start a new one.
*/
bool launchWorkerProcess(const StringArray& arguments,
const String& commandLineUniqueID,
int timeoutMs = 0,
int streamFlags = ChildProcess::wantStdOut | ChildProcess::wantStdErr);
[[deprecated ("Replaced by launchWorkerProcess.")]]
bool launchSlaveProcess (const File& executableToLaunch,
const String& commandLineUniqueID,