From 711d5ddaff965916bc2fa56fa3857a7bb773662f Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Dec 01 2009 22:42:26 +0000 Subject: - go ahead and close the pidfile at startup - remove the pidfile only if we opened it --- diff --git a/src/main.c b/src/main.c index 2c683ec..c2e3888 100644 --- a/src/main.c +++ b/src/main.c @@ -167,7 +167,9 @@ main(int argc, char **argv) fflush(pfp); } } - + if (pfp != NULL) { + fclose(pfp); + } cm_start_all(ctx); do { i = tevent_loop_once(ec); @@ -180,11 +182,7 @@ main(int argc, char **argv) cm_stop_all(ctx); talloc_free(ctx); talloc_free(ec); - if (pfp != NULL) { - fclose(pfp); - pfp = NULL; - } - if (pidfile != NULL) { + if ((pidfile != NULL) && (pfp != NULL)) { remove(pidfile); } return 0;