예제 #1
0
파일: Daemon.php 프로젝트: rlanyi/kiosk
 /**
  * Sytem_Daemon::_die()
  * Kill the daemon
  * Keep this function as independent from complex logic as possible
  *
  * @param boolean $restart Whether to restart after die
  *
  * @return void
  */
 protected static function _die($restart = false)
 {
     if (self::isDying()) {
         return null;
     }
     self::$_isDying = true;
     // Following caused a bug if pid couldn't be written because of
     // privileges
     // || !file_exists(self::opt('appPidLocation'))
     if (!self::isInBackground()) {
         self::info('Process was not daemonized yet, ' . 'just halting current process');
         die;
     }
     $pid = file_get_contents(System_Daemon::getOption('appPidLocation'));
     @unlink(self::opt('appPidLocation'));
     if ($restart) {
         // So instead we should:
         die(exec(join(' ', $GLOBALS['argv']) . ' > /dev/null &'));
     } else {
         passthru('kill -9 ' . $pid);
         die;
     }
 }
예제 #2
0
파일: Daemon.php 프로젝트: bermi/akelos
 /**
  * Sytem_Daemon::_die()
  * Kill the daemon
  * Keep this function as independent from complex logic as possible
  *
  * @param boolean $restart Whether to restart after die
  *
  * @return void
  */
 protected static function _die($restart = false)
 {
     if (!self::isDying()) {
         self::$_isDying = true;
         // Following caused a bug if pid couldn't Sbe written because of
         // privileges
         // || !file_exists(self::getOption("appPidLocation"))
         if (!self::isInBackground()) {
             self::log(self::LOG_INFO, "Not stopping " . self::getOption("appName") . ", daemon was not running", __FILE__, __CLASS__, __FUNCTION__, __LINE__);
             return false;
         }
         unlink(self::getOption("appPidLocation"));
         if ($restart) {
             // Following line blocks the exit. Leaving zombie processes:
             //die(exec(join(' ', $GLOBALS['argv'])));
             // So instead we should:
             die(exec(join(' ', $GLOBALS['argv']) . ' > /dev/null &'));
         } else {
             die;
         }
     }
 }