From b83ac58a98a2d0200ac84a640ac3ed48400c4469 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 11 Dec 2017 13:23:28 +1030 Subject: [PATCH] subd: if a required daemon exits, wait instead of killing it. Otherwise we always say it died because we killed it, so we don't get the exit status. Signed-off-by: Rusty Russell --- lightningd/subd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lightningd/subd.c b/lightningd/subd.c index 74610c9e1..a1d79c460 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -523,8 +523,13 @@ static void destroy_subd(struct subd *sd) switch (waitpid(sd->pid, &status, WNOHANG)) { case 0: - log_debug(sd->log, "Status closed, but not exited. Killing"); - kill(sd->pid, SIGKILL); + /* If it's an essential daemon, don't kill: we want the + * exit status */ + if (!sd->must_not_exit) { + log_debug(sd->log, + "Status closed, but not exited. Killing"); + kill(sd->pid, SIGKILL); + } waitpid(sd->pid, &status, 0); fail_if_subd_fails = false; break;