Fixed zombification

This commit is contained in:
buffet 2019-04-17 17:40:56 +02:00
parent 0bfd115d3c
commit 6cf3a23ad0

View file

@ -16,6 +16,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/un.h> #include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
@ -175,12 +176,28 @@ spawn_frontend(const char *path)
return false; return false;
} }
if (pid == 0) {
pid = fork();
if (pid < 0) {
wlr_log(WLR_ERROR, "Failed to start frontend (fork)");
_exit(EXIT_FAILURE);
}
if (pid == 0) { if (pid == 0) {
execlp(path, path, NULL); execlp(path, path, NULL);
wlr_log(WLR_ERROR, "Failed to start frontend (exec), continuing"); wlr_log(WLR_ERROR, "Failed to start frontend (exec), continuing");
_exit(EXIT_FAILURE); _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; return true;
} }