aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-05-21 18:15:10 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-05-21 18:15:10 +0000
commitf49742ebba769e5024f178428d6e7ad048f18e77 (patch)
treee39c97768fb208bfbc4d818b9ad1231f2f4cd7d3 /main.c
parentreadme: mention that gcc produces a much faster binary than clang (diff)
reaper: new module, uses a signalfd to wait() on child processes
Use a signalfd to listen for SIGCHLD signals. When we receive a SIGCHLD over the signalfd, reap all dead children by looping over all registered child PIDs and call waitpid(WNOHANG) on them.
Diffstat (limited to 'main.c')
-rw-r--r--main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/main.c b/main.c
index 185bb08d..b7b051f5 100644
--- a/main.c
+++ b/main.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "fdm.h"
+#include "reaper.h"
#include "render.h"
#include "server.h"
#include "shm.h"
@@ -353,6 +354,7 @@ main(int argc, char *const *argv)
conf.hold_at_exit = hold;
struct fdm *fdm = NULL;
+ struct reaper *reaper = NULL;
struct wayland *wayl = NULL;
struct renderer *renderer = NULL;
struct terminal *term = NULL;
@@ -378,6 +380,9 @@ main(int argc, char *const *argv)
if ((fdm = fdm_init()) == NULL)
goto out;
+ if ((reaper = reaper_init(fdm)) == NULL)
+ goto out;
+
if ((wayl = wayl_init(&conf, fdm)) == NULL)
goto out;
@@ -429,6 +434,7 @@ out:
shm_fini();
render_destroy(renderer);
wayl_destroy(wayl);
+ reaper_destroy(reaper);
fdm_destroy(fdm);
config_free(conf);