ErrorProcessInitiator.php 919 B

123456789101112131415161718192021222324252627282930313233343536
  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. ['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 (!str_contains($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. }