This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE3 - qdiskd: Remove pid file on clean/normal exit


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=11b4578dc96e3412489ec94547f46fb44b691913
Commit:        11b4578dc96e3412489ec94547f46fb44b691913
Parent:        ac0f47dfdbe399389a375a29d62c8f82d55a554b
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Fri Mar 20 16:38:43 2009 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Fri Mar 20 16:38:43 2009 -0400

qdiskd: Remove pid file on clean/normal exit

Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
 cman/qdisk/daemon_init.c |   16 ++++++++++++----
 cman/qdisk/main.c        |    2 ++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/cman/qdisk/daemon_init.c b/cman/qdisk/daemon_init.c
index 7a24733..33e8339 100644
--- a/cman/qdisk/daemon_init.c
+++ b/cman/qdisk/daemon_init.c
@@ -36,6 +36,7 @@ int check_process_running(char *prog, pid_t * pid);
  */
 static void update_pidfile(char *prog);
 static int setup_sigmask(void);
+static char pid_filename[PATH_MAX];
 
 static int
 check_pid_valid(pid_t pid, char *prog)
@@ -148,14 +149,13 @@ update_pidfile(char *prog)
 {
 	FILE *fp = NULL;
 	char *cmd;
-	char filename[PATH_MAX];
 
-	memset(filename, 0, PATH_MAX);
+	memset(pid_filename, 0, PATH_MAX);
 
 	cmd = basename(prog);
-	snprintf(filename, sizeof (filename), "/var/run/%s.pid", cmd);
+	snprintf(pid_filename, sizeof (pid_filename), "/var/run/%s.pid", cmd);
 
-	fp = fopen(filename, "w");
+	fp = fopen(pid_filename, "w");
 	if (fp == NULL) {
 		exit(1);
 	}
@@ -225,3 +225,11 @@ daemon_init(char *prog)
 
 	update_pidfile(prog);
 }
+
+
+void
+daemon_cleanup(void)
+{
+	if (strlen(pid_filename))
+		unlink(pid_filename);
+}
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 4b69ed8..f0ff868 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -31,6 +31,7 @@
 
 /* from daemon_init.c */
 int daemon_init(char *);
+void daemon_cleanup(void);
 int check_process_running(char *, pid_t *);
 
 /* from proc.c */
@@ -1779,6 +1780,7 @@ out:
 	}
 	qd_destroy(&ctx);
 	logt_exit();
+	daemon_cleanup();
 	return ret;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]