public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: master - qdiskd: Remove pid file on clean/normal exit
@ 2009-03-20 20:45 Lon Hohberger
0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2009-03-20 20:45 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ab7cfa4fc10c5ec6a03b3c4cad7dc94a2dfbb047
Commit: ab7cfa4fc10c5ec6a03b3c4cad7dc94a2dfbb047
Parent: 0b217a47c4c517e565888ec680bdf6f707c16a93
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:45:08 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-20 20:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-20 20:45 cluster: master - qdiskd: Remove pid file on clean/normal exit Lon Hohberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).