From 28b7d775f8996dc55be760011f946ceef8649ada Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 29 Jun 2014 15:38:15 +0100 Subject: [PATCH] Test code for juce+vfork --- .../juce_core/native/juce_posix_SharedCode.h | 18 +++++++++-------- source/utils/CarlaStringList.hpp | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/source/modules/juce_core/native/juce_posix_SharedCode.h b/source/modules/juce_core/native/juce_posix_SharedCode.h index 5e0ba4500..a7170e35b 100644 --- a/source/modules/juce_core/native/juce_posix_SharedCode.h +++ b/source/modules/juce_core/native/juce_posix_SharedCode.h @@ -1008,7 +1008,14 @@ public: if (pipe (pipeHandles) == 0) { - const pid_t result = fork(); + Array argv; + for (int i = 0; i < arguments.size(); ++i) + if (arguments[i].isNotEmpty()) + argv.add (const_cast (arguments[i].toUTF8().getAddress())); + + argv.add (nullptr); + + const pid_t result = vfork(); if (result < 0) { @@ -1017,6 +1024,7 @@ public: } else if (result == 0) { +#if 0 // we're the child process.. close (pipeHandles[0]); // close the read handle @@ -1031,13 +1039,7 @@ public: close (STDERR_FILENO); close (pipeHandles[1]); - - Array argv; - for (int i = 0; i < arguments.size(); ++i) - if (arguments[i].isNotEmpty()) - argv.add (const_cast (arguments[i].toUTF8().getAddress())); - - argv.add (nullptr); +#endif execvp (argv[0], argv.getRawDataPointer()); exit (-1); diff --git a/source/utils/CarlaStringList.hpp b/source/utils/CarlaStringList.hpp index 614815d54..740100967 100644 --- a/source/utils/CarlaStringList.hpp +++ b/source/utils/CarlaStringList.hpp @@ -206,6 +206,26 @@ public: return CharStringListPtr(*this); } + CarlaStringList& operator=(const char* const* const charStringList) noexcept + { + clear(); + + for (int i=0; charStringList[i] != nullptr; ++i) + append(charStringList[i]); + + return *this; + } + + CarlaStringList& operator=(const CarlaStringList& list) noexcept + { + clear(); + + for (Itenerator it = list.begin(); it.valid(); it.next()) + LinkedList::append(it.getValue()); + + return *this; + } + private: LinkedList fList; };