think\Process::isPtySupported PHP Method

isPtySupported() public static method

是否支持pty
public static isPtySupported ( ) : boolean
return boolean
    public static function isPtySupported()
    {
        static $result;
        if (null !== $result) {
            return $result;
        }
        if ('\\' === DS) {
            return $result = false;
        }
        $proc = @proc_open('echo 1', [['pty'], ['pty'], ['pty']], $pipes);
        if (is_resource($proc)) {
            proc_close($proc);
            return $result = true;
        }
        return $result = false;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getDescriptors()
 {
     if ($this->disableOutput) {
         $nullstream = fopen('/dev/null', 'c');
         return [['pipe', 'r'], $nullstream, $nullstream];
     }
     if ($this->ttyMode) {
         return [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']];
     }
     if ($this->ptyMode && Process::isPtySupported()) {
         return [['pty'], ['pty'], ['pty']];
     }
     return [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']];
 }