diff --git a/source/bridges-plugin/CarlaBridgePlugin.cpp b/source/bridges-plugin/CarlaBridgePlugin.cpp index a1ad407d0..42c5aed67 100644 --- a/source/bridges-plugin/CarlaBridgePlugin.cpp +++ b/source/bridges-plugin/CarlaBridgePlugin.cpp @@ -25,6 +25,10 @@ # include #endif +#ifdef CARLA_OS_LINUX +# include +#endif + #ifdef HAVE_X11 # include #endif @@ -382,6 +386,12 @@ int main(int argc, char* argv[]) rtClientBaseName[6] = '\0'; nonRtClientBaseName[6] = '\0'; nonRtServerBaseName[6] = '\0'; + +#ifdef CARLA_OS_LINUX + // terminate ourselves if main carla dies + ::prctl(PR_SET_PDEATHSIG, SIGTERM); + // TODO, osx version too, see https://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits +#endif } else { diff --git a/source/bridges-ui/CarlaBridgeUI.cpp b/source/bridges-ui/CarlaBridgeUI.cpp index 1669b45e8..a5aac878c 100644 --- a/source/bridges-ui/CarlaBridgeUI.cpp +++ b/source/bridges-ui/CarlaBridgeUI.cpp @@ -20,6 +20,11 @@ #include "CarlaBase64Utils.hpp" +#ifdef CARLA_OS_LINUX +# include +# include +#endif + // needed for atom-util #ifndef nullptr # undef NULL @@ -333,6 +338,12 @@ void CarlaBridgeUI::exec(const bool showUI) { CARLA_SAFE_ASSERT_RETURN(fToolkit != nullptr,); +#ifdef CARLA_OS_LINUX + // kill ourselves if main carla dies + ::prctl(PR_SET_PDEATHSIG, SIGKILL); + // TODO, osx version too, see https://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits +#endif + fToolkit->exec(showUI); } diff --git a/source/libjack/libjack.cpp b/source/libjack/libjack.cpp index c73c10d73..6e3b702a2 100644 --- a/source/libjack/libjack.cpp +++ b/source/libjack/libjack.cpp @@ -15,8 +15,8 @@ * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -// need to include this first #include "libjack.hpp" +#include using juce::File; using juce::FloatVectorOperations; @@ -51,6 +51,12 @@ public: const char* const libjackSetup(std::getenv("CARLA_LIBJACK_SETUP")); CARLA_SAFE_ASSERT_RETURN(libjackSetup != nullptr && std::strlen(libjackSetup) == 5,); + // make sure we don't get loaded again + carla_unsetenv("CARLA_SHM_IDS"); + + // kill ourselves if main carla dies + ::prctl(PR_SET_PDEATHSIG, SIGKILL); + for (int i=4; --i >= 0;) { CARLA_SAFE_ASSERT_RETURN(libjackSetup[i] >= '0' && libjackSetup[i] <= '0'+64,); } diff --git a/source/utils/CarlaPipeUtils.cpp b/source/utils/CarlaPipeUtils.cpp index 0a8ad0a9b..955365ccd 100644 --- a/source/utils/CarlaPipeUtils.cpp +++ b/source/utils/CarlaPipeUtils.cpp @@ -42,6 +42,9 @@ # include # include # include +# ifdef CARLA_OS_LINUX +# include +# endif #endif #ifndef F_SETPIPE_SZ @@ -1490,6 +1493,14 @@ bool CarlaPipeClient::initPipeClient(const char* argv[]) noexcept try { ::close(pipeRecvClient); } CARLA_SAFE_EXCEPTION("close(pipeRecvClient)"); try { ::close(pipeSendClient); } CARLA_SAFE_EXCEPTION("close(pipeSendClient)"); pipeRecvClient = pipeSendClient = INVALID_PIPE_VALUE; + + //---------------------------------------------------------------- + // kill ourselves if parent dies + +# ifdef CARLA_OS_LINUX + ::prctl(PR_SET_PDEATHSIG, SIGKILL); + // TODO, osx version too, see https://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits +# endif #endif //----------------------------------------------------------------