From 87e34f02c04da9dc2d254bf9f4e543ac014d712f Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 9 Dec 2006 02:39:37 +0000 Subject: - Remove pid file when exiting [benj] --- daemon/rrdbotd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'daemon/rrdbotd.c') diff --git a/daemon/rrdbotd.c b/daemon/rrdbotd.c index 9e81350..c74648d 100644 --- a/daemon/rrdbotd.c +++ b/daemon/rrdbotd.c @@ -205,6 +205,16 @@ writepid(const char* pidfile) fclose(f); } +static void +removepid(const char* pidfile) +{ + if(unlink(pidfile) < 0) + { + if(errno != ENOENT) + rb_message(LOG_WARNING, "couldn't remove pid file: %s", pidfile); + } +} + int main(int argc, char* argv[]) { @@ -353,5 +363,8 @@ main(int argc, char* argv[]) async_resolver_uninit(); server_uninit(); + if(pidfile != NULL) + removepid(pidfile); + return 0; } -- cgit v1.2.3