From 70c5e194a3c55300617abea21ac25ba1302a0b33 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 31 Mar 2012 09:22:50 +0200 Subject: [PATCH] Only remove pidfile if one was written in the first place --- miniupnpd/Changelog.txt | 5 ++++- miniupnpd/miniupnpd.c | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 8511128..08b5ab9 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,4 +1,7 @@ -$Id: Changelog.txt,v 1.264 2012/03/19 21:14:12 nanard Exp $ +$Id: Changelog.txt,v 1.265 2012/03/31 06:57:11 nanard Exp $ + +2012/03/31: + Only remove pidfile if one was written in the first place. 2012/03/19: Fix ipfilter support (thanks dhowland https://github.com/dhowland) diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 62dccc5..2c47e29 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpd.c,v 1.147 2012/02/15 22:43:56 nanard Exp $ */ +/* $Id: miniupnpd.c,v 1.149 2012/03/31 06:57:12 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2012 Thomas Bernard @@ -1038,7 +1038,8 @@ init(int argc, char * * argv, struct runtime_vars * v) return 1; } - writepidfile(pidfilename, pid); + if(writepidfile(pidfilename, pid) < 0) + pidfilename = NULL; #ifdef ENABLE_LEASEFILE /*remove(lease_file);*/ @@ -1711,7 +1712,7 @@ shutdown: close(snotify[i]); } - if(unlink(pidfilename) < 0) + if(pidfilename && (unlink(pidfilename) < 0)) { syslog(LOG_ERR, "Failed to remove pidfile %s: %m", pidfilename); }