6 public function __construct($dir, $name) {
7 $this->_file = "$dir/$name.pid";
9 if (file_exists($this->_file)) {
10 $pid = trim(file_get_contents($this->_file));
11 if (posix_kill($pid, 0)) {
12 $this->_running = true;
16 if (! $this->_running) {
18 file_put_contents($this->_file, $pid);
22 public function __destruct() {
23 if ((! $this->_running) && file_exists($this->_file)) {
28 public function is_already_running() {
29 return $this->_running;