8000 [Process] Do feat test before enabling TTY mode · symfony/symfony@69bfbbf · GitHub
[go: up one dir, main page]

Skip to content

Commit 69bfbbf

Browse files
[Process] Do feat test before enabling TTY mode
1 parent e968d0f commit 69bfbbf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,16 @@ public function setTty($tty)
911911
if ('\\' === DIRECTORY_SEPARATOR && $tty) {
912912
throw new RuntimeException('TTY mode is not supported on Windows platform.');
913913
}
914-
if ($tty && (!file_exists('/dev/tty') || !is_readable('/dev/tty'))) {
915-
throw new RuntimeException('TTY mode requires /dev/tty to be readable.');
914+
if ($tty) {
915+
static $isTtySupported;
916+
917+
if (null === $isTtySupported) {
918+
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes);
919+
}
920+
921+
if (!$isTtySupported) {
922+
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
923+
}
916924
}
917925

918926
$this->tty = (bool) $tty;
@@ -1214,7 +1222,7 @@ public static function isPtySupported()
12141222
return $result = false;
12151223
}
12161224

1217-
return $result = (bool) @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
1225+
return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
12181226
}
12191227

12201228
/**

0 commit comments

Comments
 (0)
0