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')); }
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()); }
/** * 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')); }