ErrorProcessInitiator.php 924 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Process\Tests;
  11. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  12. use Symfony\Component\Process\Process;
  13. require \dirname(__DIR__).'/vendor/autoload.php';
  14. list('e' => $php) = getopt('e:') + ['e' => 'php'];
  15. try {
  16. $process = new Process("exec $php -r \"echo 'ready'; trigger_error('error', E_USER_ERROR);\"");
  17. $process->start();
  18. $process->setTimeout(0.5);
  19. while (false === strpos($process->getOutput(), 'ready')) {
  20. usleep(1000);
  21. }
  22. $process->signal(SIGSTOP);
  23. $process->wait();
  24. return $process->getExitCode();
  25. } catch (ProcessTimedOutException $t) {
  26. echo $t->getMessage().PHP_EOL;
  27. return 1;
  28. }