From 1e9152366371809ebacb6027e8913faa951d77a4 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 3 Sep 2018 10:11:27 +0930 Subject: [PATCH] lightningd: remove unnecessary globals. Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 8 +++----- lightningd/lightningd.h | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index abac82e0a..9a182c30d 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -39,10 +39,6 @@ #include #include -char *bitcoin_datadir; - -int pid_fd; - static struct lightningd *new_lightningd(const tal_t *ctx) { struct lightningd *ld = tal(ctx, struct lightningd); @@ -277,6 +273,7 @@ static void daemonize_but_keep_dir(struct lightningd *ld) static void pidfile_create(const struct lightningd *ld) { char *pid; + int pid_fd; /* Create PID file */ pid_fd = open(ld->pidfile, O_WRONLY|O_CREAT, 0640); @@ -291,6 +288,8 @@ static void pidfile_create(const struct lightningd *ld) /* Get current PID and write to PID fie */ pid = tal_fmt(tmpctx, "%d\n", getpid()); write_all(pid_fd, pid, strlen(pid)); + + /* Leave file open: we close it implicitly when we exit */ } /* Yuck, we need globals here. */ @@ -472,7 +471,6 @@ int main(int argc, char *argv[]) tal_free(ld->rpc_listener); db_commit_transaction(ld->wallet->db); - close(pid_fd); remove(ld->pidfile); /* FIXME: pay can have children off tmpctx which unlink from diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 9b57c035e..4ae2d5883 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -76,6 +76,8 @@ struct lightningd { /* Are we told to run in the background. */ bool daemon; + int pid_fd; + /* Our config dir, and rpc file */ char *config_dir;