X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fpidfile.php;h=7157a6e591a2eeb6f830798c7347f002b79f2be2;hb=c105a67cd9cb0669c492cb20d1153fac1c001b56;hp=47df8d1f4624ef43fa2430d013f4000f8edad411;hpb=c3867f4ce4249079e1dba04ebfdc74457afbee7b;p=friendica.git diff --git a/include/pidfile.php b/include/pidfile.php index 47df8d1f46..7157a6e591 100644 --- a/include/pidfile.php +++ b/include/pidfile.php @@ -7,8 +7,8 @@ class pidfile { $this->_file = "$dir/$name.pid"; if (file_exists($this->_file)) { - $pid = trim(file_get_contents($this->_file)); - if (posix_kill($pid, 0)) { + $pid = trim(@file_get_contents($this->_file)); + if (($pid != "") && posix_kill($pid, 0)) { $this->_running = true; } } @@ -21,12 +21,20 @@ class pidfile { public function __destruct() { if ((! $this->_running) && file_exists($this->_file)) { - unlink($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)); + } } -?>