main: use slave's exit value as our exit value

This commit is contained in:
Daniel Eklöf 2019-08-23 17:23:47 +02:00
parent 74a0c5f3fc
commit 4e2067446a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

21
main.c
View file

@ -13,6 +13,7 @@
#include <sys/timerfd.h>
#include <sys/sysinfo.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <freetype/tttables.h>
#include <wayland-client.h>
@ -1087,6 +1088,26 @@ out:
assert(tll_length(term.render.workers.queue) == 0);
tll_free(term.render.workers.queue);
if (term.slave > 0) {
/* Note: we've closed ptmx, so the slave *should* exit... */
int status;
waitpid(term.slave, &status, 0);
int child_ret = EXIT_FAILURE;
if (WIFEXITED(status)) {
child_ret = WEXITSTATUS(status);
LOG_DBG("slave exited with code %d", child_ret);
} else if (WIFSIGNALED(status)) {
child_ret = WTERMSIG(status);
LOG_WARN("slave exited with signal %d", child_ret);
} else {
LOG_WARN("slave exited for unknown reason (status = 0x%08x)", status);
}
if (ret == EXIT_SUCCESS)
ret = child_ret;
}
config_free(conf);
return ret;