[Process] Fix process status in TTY mode
When running a process with TTY mode, status in automatically set to `terminated` once it's started. It's wrong for two reasons : - The status of the process is not yet terminated. - The exitcode value is never caught
This commit is contained in:
parent
1017d83260
commit
51c70f85dd
@ -248,8 +248,6 @@ class Process
|
|||||||
$this->processPipes->unblock();
|
$this->processPipes->unblock();
|
||||||
|
|
||||||
if ($this->tty) {
|
if ($this->tty) {
|
||||||
$this->status = self::STATUS_TERMINATED;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +223,26 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||||
$process->setTTY(true);
|
$process->setTTY(true);
|
||||||
$process->run();
|
$process->start();
|
||||||
|
$this->assertTrue($process->isRunning());
|
||||||
|
$process->wait();
|
||||||
|
|
||||||
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
|
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTTYCommandExitCode()
|
||||||
|
{
|
||||||
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
$this->markTestSkipped('Windows does have /dev/tty support');
|
||||||
|
}
|
||||||
|
|
||||||
|
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||||
|
$process->setTTY(true);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
public function testExitCodeText()
|
public function testExitCodeText()
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('');
|
$process = $this->getProcess('');
|
||||||
|
@ -144,6 +144,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
parent::testIsNotSuccessful();
|
parent::testIsNotSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testTTYCommandExitCode()
|
||||||
|
{
|
||||||
|
parent::testTTYCommandExitCode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user