aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-23 15:23:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-23 15:23:47 +0000
commit4e2067446afc7c60f24e9622f9227c003871cd8f (patch)
tree7fc11cded413977ace68eaa984b6b0c35bc58e8a
parentrender: change resize debug log message to an info log message (diff)
main: use slave's exit value as our exit value
-rw-r--r--main.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/main.c b/main.c
index d63f4402..ca88dae7 100644
--- a/main.c
+++ b/main.c
@@ -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;