Create a "isTtySupported" static method
This commit is contained in:
parent
cfdc145dab
commit
a1398f6de4
@ -976,16 +976,9 @@ class Process implements \IteratorAggregate
|
|||||||
if ('\\' === DIRECTORY_SEPARATOR && $tty) {
|
if ('\\' === DIRECTORY_SEPARATOR && $tty) {
|
||||||
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
throw new RuntimeException('TTY mode is not supported on Windows platform.');
|
||||||
}
|
}
|
||||||
if ($tty) {
|
|
||||||
static $isTtySupported;
|
|
||||||
|
|
||||||
if (null === $isTtySupported) {
|
if ($tty && !self::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);
|
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
|
||||||
}
|
|
||||||
|
|
||||||
if (!$isTtySupported) {
|
|
||||||
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tty = (bool) $tty;
|
$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.
|
* Returns whether PTY is supported on the current operating system.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user