|
- diff --git a/modules/juce_core/native/juce_linux_Files.cpp b/modules/juce_core/native/juce_linux_Files.cpp
- index d2a302e3e..3dc4602ce 100644
- --- a/modules/juce_core/native/juce_linux_Files.cpp
- +++ b/modules/juce_core/native/juce_linux_Files.cpp
- @@ -211,15 +211,21 @@ bool Process::openDocument (const String& fileName, const String& parameters)
-
- const char* const argv[4] = { "/bin/sh", "-c", cmdString.toUTF8(), nullptr };
-
- - auto cpid = fork();
- +#if JUCE_USE_VFORK
- + const auto cpid = vfork();
- +#else
- + const auto cpid = fork();
- +#endif
-
- if (cpid == 0)
- {
- +#if ! JUCE_USE_VFORK
- setsid();
- +#endif
-
- // Child process
- - execve (argv[0], (char**) argv, environ);
- - exit (0);
- + if (execvp (argv[0], (char**) argv) < 0)
- + _exit (0);
- }
-
- return cpid >= 0;
- diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm
- index 1a4d07516..f385a089f 100644
- --- a/modules/juce_core/native/juce_mac_Files.mm
- +++ b/modules/juce_core/native/juce_mac_Files.mm
- @@ -92,23 +92,22 @@ namespace MacFileHelpers
- #else
- static bool launchExecutable (const String& pathAndArguments)
- {
- + const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), nullptr };
- +
- +#if JUCE_USE_VFORK
- + const auto cpid = vfork();
- +#else
- auto cpid = fork();
- +#endif
-
- if (cpid == 0)
- {
- - const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), nullptr };
- -
- // Child process
- - if (execve (argv[0], (char**) argv, nullptr) < 0)
- - exit (0);
- - }
- - else
- - {
- - if (cpid < 0)
- - return false;
- + if (execvp (argv[0], (char**) argv) < 0)
- + _exit (0);
- }
-
- - return true;
- + return cpid >= 0;
- }
- #endif
- }
- diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h
- index c79ca18ea..ad46cf390 100644
- --- a/modules/juce_core/native/juce_posix_SharedCode.h
- +++ b/modules/juce_core/native/juce_posix_SharedCode.h
- @@ -1104,7 +1104,18 @@ public:
-
- 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 pid_t result = vfork();
- +#else
- + const pid_t result = fork();
- +#endif
-
- if (result < 0)
- {
- @@ -1113,6 +1124,7 @@ public:
- }
- else if (result == 0)
- {
- +#if ! JUCE_USE_VFORK
- // we're the child process..
- close (pipeHandles[0]); // close the read handle
-
- @@ -1127,17 +1139,10 @@ public:
- dup2 (open ("/dev/null", O_WRONLY), STDERR_FILENO);
-
- 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
- {
|