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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-04-12 14:22:06 +09:30
parent 2c9b043be9
commit 6f17d8bf0c

View File

@ -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);
}