Changeset View
Changeset View
Standalone View
Standalone View
src/future/exec/ExecFuture.php
Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | /* -( Interacting With Commands )------------------------------------------ */ | ||||
* NOTE: If you call @{method:discardBuffers}, all the stdout/stderr data | * NOTE: If you call @{method:discardBuffers}, all the stdout/stderr data | ||||
* will be thrown away and the cursors will be reset. | * will be thrown away and the cursors will be reset. | ||||
* | * | ||||
* @return pair <$stdout, $stderr> pair with new output since the last call | * @return pair <$stdout, $stderr> pair with new output since the last call | ||||
* to this method. | * to this method. | ||||
* @task interact | * @task interact | ||||
*/ | */ | ||||
public function read() { | public function read() { | ||||
$stdout = $this->readStdout(); | $stdout_value = $this->readStdout(); | ||||
$stderr = $this->stderr; | |||||
if ($stderr === null) { | |||||
$stderr_value = ''; | |||||
} else { | |||||
$stderr_value = substr($stderr, $this->stderrPos); | |||||
} | |||||
$result = array( | $result = array( | ||||
$stdout, | $stdout_value, | ||||
(string)substr($this->stderr, $this->stderrPos), | $stderr_value, | ||||
); | ); | ||||
$this->stderrPos = $this->getStderrBufferLength(); | $this->stderrPos = $this->getStderrBufferLength(); | ||||
return $result; | return $result; | ||||
} | } | ||||
public function readStdout() { | public function readStdout() { | ||||
if ($this->start) { | if ($this->start) { | ||||
$this->updateFuture(); // Sync | $this->updateFuture(); // Sync | ||||
} | } | ||||
$result = (string)substr($this->stdout, $this->stdoutPos); | $stdout = $this->stdout; | ||||
if ($stdout === null) { | |||||
$result = ''; | |||||
} else { | |||||
$result = substr($stdout, $this->stdoutPos); | |||||
} | |||||
$this->stdoutPos = $this->getStdoutBufferLength(); | $this->stdoutPos = $this->getStdoutBufferLength(); | ||||
return $result; | return $result; | ||||
} | } | ||||
/** | /** | ||||
* Write data to stdin of the command. | * Write data to stdin of the command. | ||||
▲ Show 20 Lines • Show All 816 Lines • Show Last 20 Lines |