From 3509f10e30f2e7a2af63d27d432079d29765132c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 11 Apr 2017 23:12:15 -0700 Subject: [PATCH] lightningd/gossip: shut down daemon when status fd closed. Signed-off-by: Rusty Russell --- lightningd/gossip/gossip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lightningd/gossip/gossip.c b/lightningd/gossip/gossip.c index 736a9360c..872b8f8a3 100644 --- a/lightningd/gossip/gossip.c +++ b/lightningd/gossip/gossip.c @@ -608,6 +608,10 @@ int main(int argc, char *argv[]) /* stdin == control */ daemon_conn_init(daemon, &daemon->master, STDIN_FILENO, recv_req); status_setup_async(&daemon->master); + + /* When conn closes, everything is freed. */ + tal_steal(daemon->master.conn, daemon); + for (;;) { struct timer *expired = NULL; io_loop(&daemon->timers, &expired); @@ -618,8 +622,6 @@ int main(int argc, char *argv[]) timer_expired(daemon, expired); } } - - tal_free(daemon); return 0; } #endif