isPtySupported() public static method

Returns whether PTY is supported on the current operating system.
public static isPtySupported ( ) : boolean
return boolean
示例#1
0
文件: UnixPipes.php 项目: VicDeo/poc
 public function getDescriptors()
 {
     if ($this->disableOutput) {
         $nullstream = fopen('/dev/null', 'c');
         return array(array('pipe', 'r'), $nullstream, $nullstream);
     }
     if ($this->ttyMode) {
         return array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w'));
     }
     if ($this->ptyMode && Process::isPtySupported()) {
         return array(array('pty'), array('pty'), array('pty'));
     }
     return array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
 }
 /**
  * Returns an array of descriptors for the use of proc_open.
  *
  * @return array
  */
 public function getDescriptors()
 {
     if ($this->disableOutput) {
         $nullstream = fopen(defined('PHP_WINDOWS_VERSION_BUILD') ? 'NUL' : '/dev/null', 'c');
         return array(array('pipe', 'r'), $nullstream, $nullstream);
     }
     if ($this->useFiles) {
         // We're not using pipe on Windows platform as it hangs (https://bugs.php.net/bug.php?id=51800)
         // We're not using file handles as it can produce corrupted output https://bugs.php.net/bug.php?id=65650
         // So we redirect output within the commandline and pass the nul device to the process
         return array(array('pipe', 'r'), array('file', 'NUL', 'w'), array('file', 'NUL', 'w'));
     }
     if ($this->ttyMode) {
         return array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w'));
     } elseif ($this->ptyMode && Process::isPtySupported()) {
         return array(array('pty'), array('pty'), array('pty'));
     }
     return array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
 }
示例#3
0
 public function testPTYCommand()
 {
     if (!Process::isPtySupported()) {
         $this->markTestSkipped('PTY is not supported on this operating system.');
     }
     $process = $this->getProcess('echo "foo"');
     $process->setPty(true);
     $process->run();
     $this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
     $this->assertEquals("foo\r\n", $process->getOutput());
 }
示例#4
0
 /**
  * Returns an array of descriptors for the use of proc_open.
  *
  * @return array
  */
 public function getDescriptors()
 {
     if ($this->useFiles) {
         return array(array('pipe', 'r'), $this->fileHandles[Process::STDOUT], array('pipe', 'w'));
     }
     if ($this->ttyMode) {
         return array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w'));
     } elseif ($this->ptyMode && Process::isPtySupported()) {
         return array(array('pty'), array('pty'), array('pty'));
     }
     return array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
 }