From 6cf3a23ad09698efbb3808124a989b778366cf05 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Wed, 17 Apr 2019 17:40:56 +0200 Subject: [PATCH] Fixed zombification --- kiwmi/frontend.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kiwmi/frontend.c b/kiwmi/frontend.c index f805742..eeae856 100644 --- a/kiwmi/frontend.c +++ b/kiwmi/frontend.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -176,9 +177,25 @@ spawn_frontend(const char *path) } if (pid == 0) { - execlp(path, path, NULL); - wlr_log(WLR_ERROR, "Failed to start frontend (exec), continuing"); - _exit(EXIT_FAILURE); + pid = fork(); + + if (pid < 0) { + wlr_log(WLR_ERROR, "Failed to start frontend (fork)"); + _exit(EXIT_FAILURE); + } + + if (pid == 0) { + execlp(path, path, NULL); + wlr_log(WLR_ERROR, "Failed to start frontend (exec), continuing"); + _exit(EXIT_FAILURE); + } + + _exit(EXIT_SUCCESS); + } + + if (waitpid(pid, NULL, 0) < 0) { + wlr_log(WLR_ERROR, "Failed to start frontend (waitpid)"); + return false; } return true;