From 6b86d087d2a28975f52e68cf7814da173fb41da6 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 2 Sep 2009 15:06:50 -0700 Subject: [PATCH] Unlink the pidfile if it exists but cannot be opened. --- source3/lib/pidfile.c | 4 ++++ source4/smbd/pidfile.c | 4 ++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/source3/lib/pidfile.c b/source3/lib/pidfile.c index 2c52d12..48a45fb 100644 --- a/source3/lib/pidfile.c +++ b/source3/lib/pidfile.c @@ -43,6 +43,10 @@ pid_t pidfile_pid(const char *name) fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644); if (fd == -1) { + if (errno != ENOENT) { + unlink(pidFile); + } + SAFE_FREE(pidFile); return 0; } diff --git a/source4/smbd/pidfile.c b/source4/smbd/pidfile.c index 44600d3..eb39aa9 100644 --- a/source4/smbd/pidfile.c +++ b/source4/smbd/pidfile.c @@ -44,6 +44,10 @@ pid_t pidfile_pid(const char *piddir, const char *name) fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644); if (fd == -1) { + if (errno != ENOENT) { + unlink(pidFile); + } + SAFE_FREE(pidFile); return 0; } -- 1.6.4.2