Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Process] Fix infinite waiting for stopped process
- Loading branch information
1 parent
9e4d5ff
commit 6b9ee1e
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Process\Tests; | ||
|
||
use Symfony\Component\Process\Exception\ProcessTimedOutException; | ||
use Symfony\Component\Process\Process; | ||
|
||
require \dirname(__DIR__).'/vendor/autoload.php'; | ||
|
||
list('e' => $php) = getopt('e:') + ['e' => 'php']; | ||
|
||
try { | ||
$process = new Process("exec $php -r \"echo 'ready'; trigger_error('error', E_USER_ERROR);\""); | ||
$process->start(); | ||
$process->setTimeout(0.5); | ||
while (false === strpos($process->getOutput(), 'ready')) { | ||
usleep(1000); | ||
} | ||
$process->signal(SIGSTOP); | ||
$process->wait(); | ||
|
||
return $process->getExitCode(); | ||
} catch (ProcessTimedOutException $t) { | ||
echo $t->getMessage().PHP_EOL; | ||
|
||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters