diff options
| author | Nikolai Nechaev <nikolay_nechaev@mail.ru> | 2025-09-24 02:32:48 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-23 19:32:48 +0200 |
| commit | 29b103c3762d01c9711aba33985f27869238143d (patch) | |
| tree | da6a4fba108d13a5624558b9824f9ae58124e931 /src/main.cpp | |
| parent | 70a7047ee175d2e7fca1575d50a3738ac40fd2c6 (diff) | |
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.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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 <csignal> #include <cstdio> #include <hyprutils/string/String.hpp> #include <hyprutils/memory/Casts.hpp> @@ -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. |
