diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 0c6f40c707..27df1361e9 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -976,16 +976,9 @@ class Process implements \IteratorAggregate if ('\\' === DIRECTORY_SEPARATOR && $tty) { throw new RuntimeException('TTY mode is not supported on Windows platform.'); } - if ($tty) { - static $isTtySupported; - if (null === $isTtySupported) { - $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); - } - - if (!$isTtySupported) { - throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.'); - } + if ($tty && !self::isTtySupported()) { + throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.'); } $this->tty = (bool) $tty; @@ -1169,6 +1162,22 @@ class Process implements \IteratorAggregate } } + /** + * Returns whether TTY is supported on the current operating system. + * + * @return bool + */ + public static function isTtySupported() + { + static $isTtySupported; + + if (null === $isTtySupported) { + $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); + } + + return $isTtySupported; + } + /** * Returns whether PTY is supported on the current operating system. *