Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if ($this->runnable) {
         $this->runnable->run();
     }
     return null;
 }
Пример #2
0
 /**
  * Capture output
  *
  * @param   lang.Runnable r
  * @param   array<string, string> initial
  * @return  array<string, string>
  */
 public static function capture(Runnable $r, $initial = array())
 {
     self::$streams = $initial;
     stream_wrapper_unregister('php');
     stream_wrapper_register('php', __CLASS__);
     try {
         $r->run();
     } catch (Exception $e) {
     }
     ensure($e);
     stream_wrapper_restore('php');
     if ($e) {
         throw $e;
     }
     return self::$streams;
 }
Пример #3
0
 static function run(Runnable $runnable)
 {
     $pid = pcntl_fork();
     if ($pid == -1) {
         throw new \ErrorException('Inability to Launch Runnable');
     } elseif ($pid) {
         // Parent
         return $pid;
     } else {
         //Child
         register_shutdown_function(function () {
             posix_kill(posix_getpid(), SIGHUP);
         });
         $runnable->run();
         exit(1);
     }
 }