<?php function single() { static $fp; $fp = fopen(__FILE__, "r"); if (is_resource($fp) == false) { throw new \RuntimeException("unable open self"); } $wouldBlock = false; if (flock($fp, LOCK_EX|LOCK_NB, $wouldBlock) == false) { if ($wouldBlock) { return false; } throw new \RuntimeException("unable lock self"); } return true; } if (single() == false) { echo "process is running.\n"; exit(); } $pid =