From 6f17d8bf0c68f13da5f572f176eb354fed4092ef Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 12 Apr 2023 14:22:06 +0930 Subject: [PATCH] lightningd: fix 100% CPU hang on shutdown. This finally happened on my test box; tests simply stopped. Turns out we were spinning here, with waitpid returning -1. Since this is during shutdown, that also explains why pytest under CI would hang, since timeouts don't apply during test teardown! Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index c60e01275..817edc81f 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -827,7 +827,7 @@ static struct io_plan *sigchld_rfd_in(struct io_conn *conn, int wstatus; /* Reap the plugins, since we otherwise ignore them. */ - while ((childpid = waitpid(-1, &wstatus, WNOHANG)) != 0) { + while ((childpid = waitpid(-1, &wstatus, WNOHANG)) > 0) { maybe_subd_child(ld, childpid, wstatus); }