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] --- ChangeLog | 3 ++- daemon/rrdbotd.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6732d4d..74b4741 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,8 @@ - Added SNMP version 2c support for rrdbot-get [Stoned Elipot] - Fixed asynchronous resolving on FreeBSD - Fix bug where rrdbot-create ignored '-c' argument [benj] - + - Remove pid file when exiting [benj] + 0.4 - Reduced memory usage of SNMP requests - Added asynchronous DNS resolver 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