public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: master - qdiskd: Remove pid file on clean/normal exit Date: Fri, 20 Mar 2009 20:45:00 -0000 [thread overview] Message-ID: <20090320204523.7C4E91202D3@lists.fedorahosted.org> (raw) 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; }
reply other threads:[~2009-03-20 20:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090320204523.7C4E91202D3@lists.fedorahosted.org \ --to=lon@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).