Skip to content

Commit 544e43f

Browse files
committed
bug #10763 [Process] Disable TTY mode on Windows platform (romainneutron)
This PR was merged into the 2.3 branch. Discussion ---------- [Process] Disable TTY mode on Windows platform | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Commits ------- 7942c2a [Process] Disable TTY mode on Windows platform
2 parents 67be447 + 7942c2a commit 544e43f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Symfony/Component/Process/Process.php

+6
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,15 @@ public function setTimeout($timeout)
771771
* @param bool $tty True to enabled and false to disable
772772
*
773773
* @return self The current Process instance
774+
*
775+
* @throws RuntimeException In case the TTY mode is not supported
774776
*/
775777
public function setTty($tty)
776778
{
779+
if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) {
780+
throw new RuntimeException('TTY mode is not supported on Windows platform.');
781+
}
782+
777783
$this->tty = (bool) $tty;
778784

779785
return $this;

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function testTTYCommand()
266266
}
267267

268268
$process = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"');
269-
$process->setTTY(true);
269+
$process->setTty(true);
270270
$process->start();
271271
$this->assertTrue($process->isRunning());
272272
$process->wait();
@@ -281,12 +281,24 @@ public function testTTYCommandExitCode()
281281
}
282282

283283
$process = $this->getProcess('echo "foo" >> /dev/null');
284-
$process->setTTY(true);
284+
$process->setTty(true);
285285
$process->run();
286286

287287
$this->assertTrue($process->isSuccessful());
288288
}
289289

290+
public function testTTYInWindowsEnvironment()
291+
{
292+
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
293+
$this->markTestSkipped('This test is for Windows platform only');
294+
}
295+
296+
$process = $this->getProcess('echo "foo" >> /dev/null');
297+
$process->setTty(false);
298+
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'TTY mode is not supported on Windows platform.');
299+
$process->setTty(true);
300+
}
301+
290302
public function testExitCodeTextIsNullWhenExitCodeIsNull()
291303
{
292304
$process = $this->getProcess('');

0 commit comments

Comments
 (0)