summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroki Tagato <tagattie@gmail.com>2026-01-06 22:38:25 +0900
committerGitHub <noreply@github.com>2026-01-06 14:38:25 +0100
commitf1652b295130fd241bd3a6505908d6db562fdcf1 (patch)
tree8bc9bc08427a307b8c72903bf8398480bd71e0ca
parentcbfbd9712a7218b6d39b4e9d93d0941eb0572783 (diff)
start: add parent-death handling for BSDs (#12863)
* Add parent-death handling for BSDs prctl() is a system call specific to Linux. So we cannot use it on BSDs. FreeBSD has a system call procctl() which is similar to prctl(). We can use it with PROC_PDEATHSIG_CTL. OpenBSD, NetBSD, and DragonFly BSD do not appear to have a similar mechanism. So intead of relying on a system call, we need to manually poll ppid to see if the parent process has died. With the changes, the spawned Hyprland process is terminated when the launcher process exits, matching Linux behavior as closely as possible on BSD platforms. * Remove ppid polling on OpenBSD, NetBSD, and DragonFly BSD
-rw-r--r--start/src/core/Instance.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/start/src/core/Instance.cpp b/start/src/core/Instance.cpp
index c89d9d0b..ec56cc75 100644
--- a/start/src/core/Instance.cpp
+++ b/start/src/core/Instance.cpp
@@ -7,11 +7,17 @@
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/prctl.h>
#include <unistd.h>
#include <ranges>
#include <string_view>
+#if defined(__linux__)
+#include <sys/prctl.h>
+#elif defined(__FreeBSD__)
+#include <signal.h>
+#include <sys/procctl.h>
+#endif
+
#include <hyprutils/os/Process.hpp>
using namespace Hyprutils::OS;
@@ -41,7 +47,12 @@ void CHyprlandInstance::runHyprlandThread(bool safeMode) {
int forkRet = fork();
if (forkRet == 0) {
// Make hyprland die on our SIGKILL
+#if defined(__linux__)
prctl(PR_SET_PDEATHSIG, SIGKILL);
+#elif defined(__FreeBSD__)
+ int sig = SIGKILL;
+ procctl(P_PID, getpid(), PROC_PDEATHSIG_CTL, &sig);
+#endif
execvp(g_state->customPath.value_or("Hyprland").c_str(), args.data());
@@ -164,4 +175,4 @@ bool CHyprlandInstance::run(bool safeMode) {
m_hlThread.join();
return !m_hyprlandInitialized || m_hyprlandExiting;
-} \ No newline at end of file
+}