Changeset View
Changeset View
Standalone View
Standalone View
src/future/exec/ExecFuture.php
| Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | /* -( Resolving Execution )------------------------------------------------ */ | ||||
| /** | /** | ||||
| * Resolve the process by abruptly terminating it. | * Resolve the process by abruptly terminating it. | ||||
| * | * | ||||
| * @return list List of <err, stdout, stderr> results. | * @return list List of <err, stdout, stderr> results. | ||||
| * @task resolve | * @task resolve | ||||
| */ | */ | ||||
| public function resolveKill() { | public function resolveKill() { | ||||
| if (!$this->result) { | if (!$this->hasResult()) { | ||||
| $signal = 9; | $signal = 9; | ||||
| if ($this->proc) { | if ($this->proc) { | ||||
| proc_terminate($this->proc, $signal); | proc_terminate($this->proc, $signal); | ||||
| } | } | ||||
| $this->result = array( | $result = array( | ||||
| 128 + $signal, | 128 + $signal, | ||||
| $this->stdout, | $this->stdout, | ||||
| $this->stderr, | $this->stderr, | ||||
| ); | ); | ||||
| $this->setResult($result); | |||||
| $this->closeProcess(); | $this->closeProcess(); | ||||
| } | } | ||||
| return $this->result; | return $this->getResult(); | ||||
| } | } | ||||
| /* -( Internals )---------------------------------------------------------- */ | /* -( Internals )---------------------------------------------------------- */ | ||||
| /** | /** | ||||
| * Provides read sockets to the future core. | * Provides read sockets to the future core. | ||||
| ▲ Show 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | if ($is_done) { | ||||
| // terminating signal code. | // terminating signal code. | ||||
| $err = $status['exitcode']; | $err = $status['exitcode']; | ||||
| if ($err == -1) { | if ($err == -1) { | ||||
| if ($status['signaled']) { | if ($status['signaled']) { | ||||
| $err = 128 + $status['termsig']; | $err = 128 + $status['termsig']; | ||||
| } | } | ||||
| } | } | ||||
| $this->result = array( | $result = array( | ||||
| $err, | $err, | ||||
| $this->stdout, | $this->stdout, | ||||
| $this->stderr, | $this->stderr, | ||||
| ); | ); | ||||
| $this->setResult($result); | |||||
| $this->closeProcess(); | $this->closeProcess(); | ||||
| return true; | return true; | ||||
| } | } | ||||
| $elapsed = (microtime(true) - $this->start); | $elapsed = (microtime(true) - $this->start); | ||||
| if ($this->terminateTimeout && ($elapsed >= $this->terminateTimeout)) { | if ($this->terminateTimeout && ($elapsed >= $this->terminateTimeout)) { | ||||
| if (!$this->didTerminate) { | if (!$this->didTerminate) { | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if ($this->proc) { | ||||
| $this->proc = null; | $this->proc = null; | ||||
| } | } | ||||
| $this->stdin = null; | $this->stdin = null; | ||||
| unset($this->windowsStdoutTempFile); | unset($this->windowsStdoutTempFile); | ||||
| unset($this->windowsStderrTempFile); | unset($this->windowsStderrTempFile); | ||||
| if ($this->profilerCallID !== null) { | if ($this->profilerCallID !== null) { | ||||
| if ($this->hasResult()) { | |||||
| $result = $this->getResult(); | |||||
| $err = idx($result, 0); | |||||
| } else { | |||||
| $err = null; | |||||
| } | |||||
| $profiler = PhutilServiceProfiler::getInstance(); | $profiler = PhutilServiceProfiler::getInstance(); | ||||
| $profiler->endServiceCall( | $profiler->endServiceCall( | ||||
| $this->profilerCallID, | $this->profilerCallID, | ||||
| array( | array( | ||||
| 'err' => $this->result ? idx($this->result, 0) : null, | 'err' => $err, | ||||
| )); | )); | ||||
| $this->profilerCallID = null; | $this->profilerCallID = null; | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Execute `proc_get_status()`, but avoid pitfalls. | * Execute `proc_get_status()`, but avoid pitfalls. | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||