From 29b103c3762d01c9711aba33985f27869238143d Mon Sep 17 00:00:00 2001 From: Nikolai Nechaev Date: Wed, 24 Sep 2025 02:32:48 +0900 Subject: exec: Spawn processes as direct children (#11735) * exec: Spawn processes as direct children Spawn processes as children rather than grandchildren. This way, spawned processes may track Hyprland's state by watching their parent, either directly or indirectly (e.g., Linux's `PR_SET_PDEATH_SIG`). Fixes #11728 * tests/exec: Add the test on process spawning Add a test that ensures that: - A spawned process remains a direct child of Hyprland; - Upon termination, the process does not become a zombie. --- src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 8467ea6e..b0f8b66c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include "init/initHelpers.hpp" #include "debug/HyprCtl.hpp" +#include #include #include #include @@ -35,6 +36,17 @@ static void help() { --version -v - Print this binary's version)"); } +static void reapZombieChildrenAutomatically() { + struct sigaction act; + act.sa_handler = SIG_DFL; + sigemptyset(&act.sa_mask); + act.sa_flags = SA_NOCLDWAIT; +#ifdef SA_RESTORER + act.sa_restorer = NULL; +#endif + sigaction(SIGCHLD, &act, nullptr); +} + int main(int argc, char** argv) { if (!getenv("XDG_RUNTIME_DIR")) @@ -183,6 +195,8 @@ int main(int argc, char** argv) { if (!envEnabled("HYPRLAND_NO_RT")) NInit::gainRealTime(); + reapZombieChildrenAutomatically(); + Debug::log(LOG, "Hyprland init finished."); // If all's good to go, start. -- cgit v1.2.3