Changeset View
Changeset View
Standalone View
Standalone View
src/future/exec/ExecFuture.php
Show First 20 Lines • Show All 707 Lines • ▼ Show 20 Lines | if (!$this->proc) { | ||||
return true; | return true; | ||||
} | } | ||||
list($stdin, $stdout, $stderr) = $this->pipes; | list($stdin, $stdout, $stderr) = $this->pipes; | ||||
while (isset($this->stdin) && $this->stdin->getByteLength()) { | while (isset($this->stdin) && $this->stdin->getByteLength()) { | ||||
$write_segment = $this->stdin->getAnyPrefix(); | $write_segment = $this->stdin->getAnyPrefix(); | ||||
try { | |||||
$bytes = fwrite($stdin, $write_segment); | $bytes = fwrite($stdin, $write_segment); | ||||
} catch (RuntimeException $ex) { | |||||
// If the subprocess has exited, we may get a broken pipe error here | |||||
// in recent versions of PHP. There does not seem to be any way to | |||||
// get the actual error code other than reading the exception string. | |||||
// For now, treat this as if writes are blocked. | |||||
break; | |||||
} | |||||
if ($bytes === false) { | if ($bytes === false) { | ||||
throw new Exception(pht('Unable to write to stdin!')); | throw new Exception(pht('Unable to write to stdin!')); | ||||
} else if ($bytes) { | } else if ($bytes) { | ||||
$this->stdin->removeBytesFromHead($bytes); | $this->stdin->removeBytesFromHead($bytes); | ||||
} else { | } else { | ||||
// Writes are blocked for now. | // Writes are blocked for now. | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |