From a41ab650e568137b0fe6b156d3c58c396d975e6b Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 7 Apr 2018 14:42:00 +0200 Subject: [PATCH] master: Move pid-file creation after the daemonization Creating the pid-file before daemonizing results in the pid-file containing the pid of the process that started the daemon, but is now dead. Signed-off-by: Christian Decker Reported-By: Torkel Rogstad @torkelrogstad --- lightningd/lightningd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index f5e22a533..d671cf712 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -290,9 +290,6 @@ int main(int argc, char *argv[]) /* Handle options and config; move to .lightningd */ newdir = handle_opts(ld, argc, argv); - /* Create PID file */ - pidfile_create(ld); - /* Ignore SIGPIPE: we look at our write return values*/ signal(SIGPIPE, SIG_IGN); @@ -373,6 +370,9 @@ int main(int argc, char *argv[]) if (ld->daemon) daemonize_but_keep_dir(ld); + /* Create PID file */ + pidfile_create(ld); + /* Mark ourselves live. */ log_info(ld->log, "Server started with public key %s, alias %s (color #%s) and lightningd %s", type_to_string(tmpctx, struct pubkey, &ld->id),