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.
This commit is contained in:
parent
70a7047ee1
commit
29b103c376
3 changed files with 95 additions and 38 deletions
14
src/main.cpp
14
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue