From df6913f7e1eb86e441c9a4a996d59241f95af0b5 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 27 Feb 2017 06:31:49 +0000 Subject: [PATCH] pidfile.php is in use by two addons. So we restore it here. --- include/pidfile.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/pidfile.php diff --git a/include/pidfile.php b/include/pidfile.php new file mode 100644 index 0000000000..3093e149ae --- /dev/null +++ b/include/pidfile.php @@ -0,0 +1,41 @@ +_file = "$dir/$name.pid"; + + if (file_exists($this->_file)) { + $pid = trim(@file_get_contents($this->_file)); + if (($pid != "") AND posix_kill($pid, 0)) { + $this->_running = true; + } + } + + if (! $this->_running) { + $pid = getmypid(); + file_put_contents($this->_file, $pid); + } + } + + public function __destruct() { + if ((! $this->_running) && file_exists($this->_file)) { + @unlink($this->_file); + } + } + + public function is_already_running() { + return $this->_running; + } + + public function running_time() { + return(time() - @filectime($this->_file)); + } + + public function kill() { + if (file_exists($this->_file)) + return(posix_kill(file_get_contents($this->_file), SIGTERM)); + } +} +?> -- 2.39.5