From 66290d132f9e7038488cb35a804c8c910473e82f Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 7 Jan 2017 08:13:57 +0100 Subject: [PATCH] pidfile: Re-create file on consequetive calls if it doesn't exist Signed-off-by: Joachim Nilsson --- pidfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pidfile.c b/pidfile.c index 51c4a17..7fe7ae5 100644 --- a/pidfile.c +++ b/pidfile.c @@ -65,7 +65,7 @@ pidfile(const char *basename) atexit_already = 0; if (pidfile_path != NULL) { - if (pid == pidfile_pid) { + if (!access(pidfile_path, R_OK) && pid == pidfile_pid) { utimensat(0, pidfile_path, NULL, 0); return (0); } @@ -96,6 +96,7 @@ pidfile(const char *basename) return (-1); } (void) fclose(f); + __pidfile_name = pidfile_path; /* * LITE extension, no need to set up another atexit() handler @@ -114,7 +115,6 @@ pidfile(const char *basename) errno = save_errno; return (-1); } - __pidfile_name = pidfile_path; return (0); }