From 85562db4322ee9ab31f654ebc5bdcc6ef7ecc859 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 29 Jun 2021 14:18:05 +0930 Subject: [PATCH] lightningd: print out what errno we got if unexpected in sigchild. Looking at #4575, I'm not sure what happened. This prints it out, at least. Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 01fb41ef5..4272d7b6f 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -713,8 +713,13 @@ static void on_sigchild(int _ UNUSED) * there are no more children. But glibc's overzealous use of * __attribute__((warn_unused_result)) means we have to * "catch" the return value. */ - if (write(sigchld_wfd, "", 1) != 1) - assert(errno == EAGAIN || errno == EWOULDBLOCK); + if (write(sigchld_wfd, "", 1) != 1) { + if (errno != EAGAIN && errno == EWOULDBLOCK) { + /* Should not call this in a signal handler, but we're + * already messed up! */ + fatal("on_sigchild: write errno %s", strerror(errno)); + } + } } /*~ We only need to handle SIGTERM and SIGINT for the case we are PID 1 of