@@ -206,17 +206,22 @@ bool Process::openDocument (const String& fileName, const String& parameters) | |||||
cmdString = cmdLines.joinIntoString (" || "); | cmdString = cmdLines.joinIntoString (" || "); | ||||
} | } | ||||
const char* const argv[4] = { "/bin/sh", "-c", cmdString.toUTF8(), 0 }; | |||||
const char* const argv[4] = { "/bin/sh", "-c", cmdString.toUTF8(), nullptr }; | |||||
#if JUCE_USE_VFORK | |||||
const int cpid = vfork(); | |||||
#else | |||||
const int cpid = fork(); | const int cpid = fork(); | ||||
#endif | |||||
if (cpid == 0) | if (cpid == 0) | ||||
{ | { | ||||
#if ! JUCE_USE_VFORK | |||||
setsid(); | setsid(); | ||||
#endif | |||||
// Child process | // Child process | ||||
execve (argv[0], (char**) argv, environ); | |||||
exit (0); | |||||
if (execvp (argv[0], (char**) argv) < 0) | |||||
_exit (0); | |||||
} | } | ||||
return cpid >= 0; | return cpid >= 0; | ||||
@@ -102,23 +102,22 @@ namespace MacFileHelpers | |||||
#else | #else | ||||
static bool launchExecutable (const String& pathAndArguments) | static bool launchExecutable (const String& pathAndArguments) | ||||
{ | { | ||||
const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), 0 }; | |||||
const char* const argv[4] = { "/bin/sh", "-c", pathAndArguments.toUTF8(), nullptr }; | |||||
#if JUCE_USE_VFORK | |||||
const int cpid = vfork(); | |||||
#else | |||||
const int cpid = fork(); | const int cpid = fork(); | ||||
#endif | |||||
if (cpid == 0) | if (cpid == 0) | ||||
{ | { | ||||
// Child process | // Child process | ||||
if (execve (argv[0], (char**) argv, 0) < 0) | |||||
exit (0); | |||||
} | |||||
else | |||||
{ | |||||
if (cpid < 0) | |||||
return false; | |||||
if (execvp (argv[0], (char**) argv) < 0) | |||||
_exit (0); | |||||
} | } | ||||
return true; | |||||
return cpid >= 0; | |||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
@@ -1160,7 +1160,18 @@ public: | |||||
if (pipe (pipeHandles) == 0) | if (pipe (pipeHandles) == 0) | ||||
{ | { | ||||
Array<char*> argv; | |||||
for (int i = 0; i < arguments.size(); ++i) | |||||
if (arguments[i].isNotEmpty()) | |||||
argv.add (const_cast<char*> (arguments[i].toRawUTF8())); | |||||
argv.add (nullptr); | |||||
#if JUCE_USE_VFORK | |||||
const pid_t result = vfork(); | |||||
#else | |||||
const pid_t result = fork(); | const pid_t result = fork(); | ||||
#endif | |||||
if (result < 0) | if (result < 0) | ||||
{ | { | ||||
@@ -1169,6 +1180,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 | ||||
@@ -1183,16 +1195,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 (int i = 0; i < arguments.size(); ++i) | |||||
if (arguments[i].isNotEmpty()) | |||||
argv.add (const_cast<char*> (arguments[i].toRawUTF8())); | |||||
argv.add (nullptr); | |||||
execvp (exe.toRawUTF8(), argv.getRawDataPointer()); | |||||
exit (-1); | |||||
if (execvp (argv[0], argv.getRawDataPointer()) < 0) | |||||
_exit (-1); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||