From 96bb55368883f79c33676b4c02195fb19551e9ef Mon Sep 17 00:00:00 2001 From: yuqing Date: Thu, 11 Feb 2016 13:55:44 +0800 Subject: [PATCH] delete pid file check pid --- HISTORY | 2 +- src/process_ctrl.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 35a2bd6..381763b 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,5 @@ -Version 1.24 2016-01-28 +Version 1.24 2016-02-11 * php extension compiled on PHP 7 * add skiplist which support stable sort * make.sh: use sed to replace perl diff --git a/src/process_ctrl.c b/src/process_ctrl.c index a62ca77..3b6f917 100644 --- a/src/process_ctrl.c +++ b/src/process_ctrl.c @@ -42,6 +42,17 @@ int write_to_pid_file(const char *pidFilename) int delete_pid_file(const char *pidFilename) { + int result; + pid_t pid; + + if ((result=get_pid_from_file(pidFilename, &pid)) != 0) { + return result; + } + + if (pid != getpid()) { + return ESRCH; + } + if (unlink(pidFilename) == 0) { return 0; }