From 9dc2244c9e2b359a9ec61d57a9aa5cebf9d452de Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Mon, 29 Mar 2021 17:28:31 -0700 Subject: [PATCH] main.c CLI: replace confusingly-used `FILE *pid_fp` with `int wrote_pid` This was last modified in 557ac6cfa, although the use of the closed `FILE *fp` (to signal the need to delete the pidfile) long pre-dates that commit. Signed-off-by: Daniel Lenski --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index cedd7c19..c940a03f 100644 --- a/main.c +++ b/main.c @@ -84,7 +84,7 @@ static int timestamp; #ifndef _WIN32 static int background; static int use_syslog = 0; -static FILE *pid_fp = NULL; +int wrote_pid = 0; static char *pidfile = NULL; #endif static int do_passphrase_from_fsid; @@ -1475,7 +1475,7 @@ static void print_connection_stats(void *_vpninfo, const struct oc_stats *stats) } #ifndef _WIN32 -static FILE *background_self(struct openconnect_info *vpninfo, char *pidfile) { +static int background_self(struct openconnect_info *vpninfo, char *pidfile) { FILE *fp = NULL; int pid; @@ -1508,7 +1508,7 @@ static FILE *background_self(struct openconnect_info *vpninfo, char *pidfile) { } if (fp) fclose(fp); - return fp; + return !!fp; } #endif /* _WIN32 */ @@ -1518,7 +1518,7 @@ static void fully_up_cb(void *_vpninfo) { print_connection_info(vpninfo); #ifndef _WIN32 if (background) - pid_fp = background_self(vpninfo, pidfile); + wrote_pid = background_self(vpninfo, pidfile); #ifndef __native_client__ if (use_syslog) { @@ -2123,7 +2123,7 @@ int main(int argc, char **argv) } #ifndef _WIN32 - if (pid_fp) + if (wrote_pid) unlink(pidfile); #endif -- 2.49.0