From 31306311561fb83a6ba5efb475139487fa8f866d Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 19 May 2015 21:10:37 +0200 Subject: [PATCH] Fix build; Send SIGTERM signal to waiting processes --- source/native-plugins/zynaddsubfx-src.cpp | 6 ++++-- source/native-plugins/zynaddsubfx-ui.cpp | 6 ++++-- source/utils/CarlaPipeUtils.cpp | 13 +++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/source/native-plugins/zynaddsubfx-src.cpp b/source/native-plugins/zynaddsubfx-src.cpp index dfb0b9228..6e512855d 100644 --- a/source/native-plugins/zynaddsubfx-src.cpp +++ b/source/native-plugins/zynaddsubfx-src.cpp @@ -18,8 +18,10 @@ #include "CarlaDefines.h" #ifdef CARLA_OS_WIN -#define errx(...) -#define warnx(...) +# define errx(...) +# define warnx(...) +#else +# include #endif #define PLUGINVERSION diff --git a/source/native-plugins/zynaddsubfx-ui.cpp b/source/native-plugins/zynaddsubfx-ui.cpp index 27e9ef14d..7fc4c70cc 100644 --- a/source/native-plugins/zynaddsubfx-ui.cpp +++ b/source/native-plugins/zynaddsubfx-ui.cpp @@ -18,8 +18,10 @@ #include "CarlaPipeUtils.cpp" #ifdef CARLA_OS_WIN -#define errx(...) -#define warnx(...) +# define errx(...) +# define warnx(...) +#else +# include #endif #define PLUGINVERSION diff --git a/source/utils/CarlaPipeUtils.cpp b/source/utils/CarlaPipeUtils.cpp index ede1788cd..83cc75ac1 100644 --- a/source/utils/CarlaPipeUtils.cpp +++ b/source/utils/CarlaPipeUtils.cpp @@ -378,7 +378,7 @@ void waitForProcessToStopOrKillIt(const PROCESS_INFORMATION& processInfo, const } #else static inline -bool waitForChildToStop(const pid_t pid, const uint32_t timeOutMilliseconds) noexcept +bool waitForChildToStop(const pid_t pid, const uint32_t timeOutMilliseconds, bool sendTerminate) noexcept { CARLA_SAFE_ASSERT_RETURN(pid > 0, false); CARLA_SAFE_ASSERT_RETURN(timeOutMilliseconds > 0, false); @@ -409,6 +409,11 @@ bool waitForChildToStop(const pid_t pid, const uint32_t timeOutMilliseconds) noe break; case 0: + if (sendTerminate) + { + sendTerminate = false; + ::kill(pid, SIGTERM); + } if (getMillisecondCounter() < timeoutEnd) { carla_msleep(5); @@ -442,14 +447,14 @@ void waitForChildToStopOrKillIt(pid_t& pid, const uint32_t timeOutMilliseconds) CARLA_SAFE_ASSERT_RETURN(pid > 0,); CARLA_SAFE_ASSERT_RETURN(timeOutMilliseconds > 0,); - if (! waitForChildToStop(pid, timeOutMilliseconds)) + if (! waitForChildToStop(pid, timeOutMilliseconds, true)) { carla_stderr("waitForChildToStopOrKillIt() - process didn't stop, force killing"); if (::kill(pid, SIGKILL) != -1) { // wait for killing to take place - waitForChildToStop(pid, timeOutMilliseconds); + waitForChildToStop(pid, timeOutMilliseconds, false); } else { @@ -1375,7 +1380,7 @@ bool CarlaPipeServer::startPipeServer(const char* const filename, const char* co if (::kill(pData->pid, SIGKILL) != -1) { // wait for killing to take place - waitForChildToStop(pData->pid, 2*1000); + waitForChildToStop(pData->pid, 2*1000, false); } pData->pid = -1; #endif