Ejemplo n.º 1
0
 protected function initAndRunTaskInSubprocess($command)
 {
     if (function_exists('pcntl_fork')) {
         // UNIX
         $argv = explode(' ', $command);
         list($task_name, $args, $options) = self::parseTaskAndParameters($argv);
         $task_name = pakeTask::get_full_task_name($task_name);
         $pid = pcntl_fork();
         if ($pid == -1) {
             die('could not fork');
         }
         if ($pid) {
             // we are the parent
             pcntl_wait($status);
             $status = pcntl_wexitstatus($status);
             if ($status == self::QUIT_INTERACTIVE) {
                 exit(0);
             }
         } else {
             try {
                 $status = $this->initAndRunTask($task_name, $args, $options);
                 if (true === $status) {
                     exit(0);
                 }
                 exit($status);
             } catch (pakeException $e) {
                 pakeException::render($e);
                 exit(1);
             }
         }
     } else {
         // WINDOWS
         $php_exec = escapeshellarg((isset($_SERVER['_']) and substr($_SERVER['_'], -4) != 'pake') ? $_SERVER['_'] : 'php');
         $force_tty = '';
         if (defined('PAKE_FORCE_TTY') or DIRECTORY_SEPARATOR != '\\' and function_exists('posix_isatty') and @posix_isatty(STDOUT)) {
             $force_tty = ' --force-tty';
         }
         $pake_php = escapeshellarg($_SERVER['SCRIPT_NAME']);
         $import_flag = ' --import=interactive';
         system($php_exec . ' ' . $pake_php . $force_tty . $import_flag . ' ' . $command, $status);
         if ($status == self::QUIT_INTERACTIVE) {
             exit(0);
         }
     }
 }
Ejemplo n.º 2
0
function pake_exception_default_handler($exception)
{
    $e = new pakeException();
    $e->render($exception);
    exit(1);
}
Ejemplo n.º 3
0
function pake_exception_default_handler($exception)
{
    pakeException::render($exception);
    exit(1);
}