Browse Source

Kill bridges (child processes) when main carla dies

tags/1.9.8
falkTX 8 years ago
parent
commit
4d14bb55fe
4 changed files with 39 additions and 1 deletions
  1. +10
    -0
      source/bridges-plugin/CarlaBridgePlugin.cpp
  2. +11
    -0
      source/bridges-ui/CarlaBridgeUI.cpp
  3. +7
    -1
      source/libjack/libjack.cpp
  4. +11
    -0
      source/utils/CarlaPipeUtils.cpp

+ 10
- 0
source/bridges-plugin/CarlaBridgePlugin.cpp View File

@@ -25,6 +25,10 @@
# include <signal.h>
#endif

#ifdef CARLA_OS_LINUX
# include <sys/prctl.h>
#endif

#ifdef HAVE_X11
# include <X11/Xlib.h>
#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
{


+ 11
- 0
source/bridges-ui/CarlaBridgeUI.cpp View File

@@ -20,6 +20,11 @@

#include "CarlaBase64Utils.hpp"

#ifdef CARLA_OS_LINUX
# include <signal.h>
# include <sys/prctl.h>
#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);
}



+ 7
- 1
source/libjack/libjack.cpp View File

@@ -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 <sys/prctl.h>

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,);
}


+ 11
- 0
source/utils/CarlaPipeUtils.cpp View File

@@ -42,6 +42,9 @@
# include <cerrno>
# include <signal.h>
# include <sys/wait.h>
# ifdef CARLA_OS_LINUX
# include <sys/prctl.h>
# 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

//----------------------------------------------------------------


Loading…
Cancel
Save