Signed-off-by: falkTX <falktx@falktx.com>v7.0.9-distrho
| @@ -218,15 +218,21 @@ bool Process::openDocument (const String& fileName, const String& parameters) | |||||
| const char* const argv[] = { "/bin/sh", "-c", cmdString.toUTF8(), nullptr }; | const char* const argv[] = { "/bin/sh", "-c", cmdString.toUTF8(), nullptr }; | ||||
| #if JUCE_USE_VFORK | |||||
| const auto cpid = vfork(); | |||||
| #else | |||||
| const auto cpid = fork(); | const auto cpid = fork(); | ||||
| #endif | |||||
| if (cpid == 0) | if (cpid == 0) | ||||
| { | { | ||||
| #if ! JUCE_USE_VFORK | |||||
| setsid(); | setsid(); | ||||
| #endif | |||||
| // Child process | // Child process | ||||
| execv (argv[0], (char**) argv); | |||||
| exit (0); | |||||
| if (execv (argv[0], (char**) argv) < 0) | |||||
| _exit (0); | |||||
| } | } | ||||
| return cpid >= 0; | return cpid >= 0; | ||||
| @@ -92,15 +92,19 @@ namespace MacFileHelpers | |||||
| #else | #else | ||||
| static bool launchExecutable (const String& pathAndArguments) | static bool launchExecutable (const String& pathAndArguments) | ||||
| { | { | ||||
| auto cpid = fork(); | |||||
| const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), nullptr }; | |||||
| #if JUCE_USE_VFORK | |||||
| const auto cpid = vfork(); | |||||
| #else | |||||
| const auto cpid = fork(); | |||||
| #endif | |||||
| if (cpid == 0) | if (cpid == 0) | ||||
| { | { | ||||
| const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), nullptr }; | |||||
| // Child process | // Child process | ||||
| if (execve (argv[0], (char**) argv, nullptr) < 0) | if (execve (argv[0], (char**) argv, nullptr) < 0) | ||||
| exit (0); | |||||
| _exit (0); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -108,7 +112,7 @@ namespace MacFileHelpers | |||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | |||||
| return cpid >= 0; | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -1136,7 +1136,19 @@ public: | |||||
| if (pipe (pipeHandles) == 0) | if (pipe (pipeHandles) == 0) | ||||
| { | { | ||||
| auto result = fork(); | |||||
| Array<char*> argv; | |||||
| for (auto& arg : arguments) | |||||
| if (arg.isNotEmpty()) | |||||
| argv.add (const_cast<char*> (arg.toRawUTF8())); | |||||
| argv.add (nullptr); | |||||
| #if JUCE_USE_VFORK | |||||
| const auto result = vfork(); | |||||
| #else | |||||
| const auto result = fork(); | |||||
| #endif | |||||
| if (result < 0) | if (result < 0) | ||||
| { | { | ||||
| @@ -1145,6 +1157,7 @@ public: | |||||
| } | } | ||||
| else if (result == 0) | else if (result == 0) | ||||
| { | { | ||||
| #if ! JUCE_USE_VFORK | |||||
| // we're the child process.. | // we're the child process.. | ||||
| close (pipeHandles[0]); // close the read handle | close (pipeHandles[0]); // close the read handle | ||||
| @@ -1159,17 +1172,10 @@ public: | |||||
| dup2 (open ("/dev/null", O_WRONLY), STDERR_FILENO); | dup2 (open ("/dev/null", O_WRONLY), STDERR_FILENO); | ||||
| close (pipeHandles[1]); | close (pipeHandles[1]); | ||||
| #endif | |||||
| Array<char*> argv; | |||||
| for (auto& arg : arguments) | |||||
| if (arg.isNotEmpty()) | |||||
| argv.add (const_cast<char*> (arg.toRawUTF8())); | |||||
| argv.add (nullptr); | |||||
| execvp (exe.toRawUTF8(), argv.getRawDataPointer()); | |||||
| _exit (-1); | |||||
| if (execvp (exe.toRawUTF8(), argv.getRawDataPointer()) < 0) | |||||
| _exit (-1); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||