Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Process] Fix infinite waiting for stopped process #31568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Process] Fix infinite waiting for stopped process
  • Loading branch information
mshavliuk authored and nicolas-grekas committed May 22, 2019
commit 6b9ee1e1c569f61d1a871671c9e2d1cdffea217b
1 change: 1 addition & 0 deletions 1 src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public function wait(callable $callback = null)
} while ($running);

while ($this->isRunning()) {
$this->checkTimeout();
usleep(1000);
}

Expand Down
36 changes: 36 additions & 0 deletions 36 src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
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;
}
9 changes: 9 additions & 0 deletions 9 src/Symfony/Component/Process/Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,15 @@ public function testEnvArgument()
$this->assertSame($env, $p->getEnv());
}

public function testWaitStoppedDeadProcess()
{
$process = $this->getProcess(self::$phpBin.' '.__DIR__.'/ErrorProcessInitiator.php -e '.self::$phpBin);
$process->start();
$process->setTimeout(2);
$process->wait();
$this->assertFalse($process->isRunning());
}

/**
* @param string $commandline
* @param string|null $cwd
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.