/** * Stops the backgroud proccess by sending it SIGKILL * * @return int The exit status code */ public function stop() { $statusCode = $this->symfonyProcess->stop(); // give the new process a bit of breathing room sleep(2); return $statusCode; }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var FormatterHelper $formatter */ $formatter = $this->getHelper('formatter'); // $process = new Process('wkhtmltopdf http://google.com/ test.pdf'); // $process->run(); // $process->stop(3, SIGINT); // $process->mustRun(function ($type, $message) use ($output, $formatter) { // if ($type === Process::ERR) { // $output->writeln($formatter->formatBlock($message, 'error')); // } else { // $output->writeln($formatter->formatBlock($message, 'comment')); // } // }); $process = new PhpProcess(<<<EOF <?php sleep(5); echo "OK "; ?> EOF ); $process->start(); $process->stop(2, SIGINT); if (!$process->isSuccessful()) { $output->writeln($formatter->formatBlock($process->getErrorOutput(), 'error', true)); return; } $output->writeln($formatter->formatSection('success', $process->getOutput())); }