From e400d81eccce56b700a1b1434cd2d993019b801b Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 18 Jun 2024 12:21:07 +0300 Subject: [PATCH] set "child subreaper" process attribute on Linux (#7315) When launching the wine VST process various wrappers may be involved, when they exit the VST process becomes orphaned. This breaks the PollParentThread mechanism which is responsible for cleaning up processes in case of a crash. Because of this 64bit VST process exits prematurely, in other words 64bit VST is currently broken in a typical wine configuration. A solution suggested by Lukas W is to set the PR_SET_CHILD_SUBREAPER flag which makes the kernel reparent such process to lmms and PollParentThread then works as intended. Co-authored-by: Lukas W --- CMakeLists.txt | 1 + src/core/main.cpp | 13 +++++++++++++ src/lmmsconfig.h.in | 1 + 3 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6aa53d982..9da4fc243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,7 @@ CHECK_INCLUDE_FILES(sys/types.h LMMS_HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILES(sys/ipc.h LMMS_HAVE_SYS_IPC_H) CHECK_INCLUDE_FILES(sys/time.h LMMS_HAVE_SYS_TIME_H) CHECK_INCLUDE_FILES(sys/times.h LMMS_HAVE_SYS_TIMES_H) +CHECK_INCLUDE_FILES(sys/prctl.h LMMS_HAVE_SYS_PRCTL_H) CHECK_INCLUDE_FILES(sched.h LMMS_HAVE_SCHED_H) CHECK_INCLUDE_FILES(sys/soundcard.h LMMS_HAVE_SYS_SOUNDCARD_H) CHECK_INCLUDE_FILES(soundcard.h LMMS_HAVE_SOUNDCARD_H) diff --git a/src/core/main.cpp b/src/core/main.cpp index 650ceab57..b970997ef 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -55,6 +55,10 @@ #include #endif +#ifdef LMMS_HAVE_SYS_PRCTL_H +#include +#endif + #include #include "MainApplication.h" @@ -293,6 +297,15 @@ int main( int argc, char * * argv ) qInstallMessageHandler(consoleMessageHandler); #endif +#if defined(LMMS_HAVE_SYS_PRCTL_H) && defined(PR_SET_CHILD_SUBREAPER) + // Set the "child subreaper" attribute so that plugin child processes remain as lmms' + // children even when some wrapper process exits, as it may happen with wine + if (prctl(PR_SET_CHILD_SUBREAPER, 1)) + { + perror("prctl(PR_SET_CHILD_SUBREAPER)"); + } +#endif + // initialize memory managers NotePlayHandleManager::init(); diff --git a/src/lmmsconfig.h.in b/src/lmmsconfig.h.in index 89db21a7b..1510a36ec 100644 --- a/src/lmmsconfig.h.in +++ b/src/lmmsconfig.h.in @@ -45,6 +45,7 @@ #cmakedefine LMMS_HAVE_SEMAPHORE_H #cmakedefine LMMS_HAVE_SYS_TIME_H #cmakedefine LMMS_HAVE_SYS_TIMES_H +#cmakedefine LMMS_HAVE_SYS_PRCTL_H #cmakedefine LMMS_HAVE_SCHED_H #cmakedefine LMMS_HAVE_SYS_SOUNDCARD_H #cmakedefine LMMS_HAVE_SOUNDCARD_H