From 4e2067446afc7c60f24e9622f9227c003871cd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 23 Aug 2019 17:23:47 +0200 Subject: [PATCH] main: use slave's exit value as our exit value --- main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main.c b/main.c index d63f4402..ca88dae7 100644 --- a/main.c +++ b/main.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -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;