Page MenuHomePhabricator

D7688.diff

diff --git a/src/future/exec/ExecFuture.php b/src/future/exec/ExecFuture.php
--- a/src/future/exec/ExecFuture.php
+++ b/src/future/exec/ExecFuture.php
@@ -400,18 +400,20 @@
* @task resolve
*/
public function resolveKill() {
- if (defined('SIGKILL')) {
- $signal = SIGKILL;
- } else {
- $signal = 9;
- }
+ if (!$this->result) {
+ if (defined('SIGKILL')) {
+ $signal = SIGKILL;
+ } else {
+ $signal = 9;
+ }
- proc_terminate($this->proc, $signal);
- $this->result = array(
- 128 + $signal,
- $this->stdout,
- $this->stderr);
- $this->closeProcess();
+ proc_terminate($this->proc, $signal);
+ $this->result = array(
+ 128 + $signal,
+ $this->stdout,
+ $this->stderr);
+ $this->closeProcess();
+ }
return $this->result;
}
diff --git a/src/future/exec/__tests__/ExecFutureTestCase.php b/src/future/exec/__tests__/ExecFutureTestCase.php
--- a/src/future/exec/__tests__/ExecFutureTestCase.php
+++ b/src/future/exec/__tests__/ExecFutureTestCase.php
@@ -109,4 +109,16 @@
$this->assertEqual(true, ($end - $start) < 5);
}
+ public function testMultipleResolves() {
+ // It should be safe to call resolve(), resolvex(), resolveKill(), etc.,
+ // as many times as you want on the same process.
+
+ $future = new ExecFuture('echo quack');
+ $future->resolve();
+ $future->resolvex();
+ list($err) = $future->resolveKill();
+
+ $this->assertEqual(0, $err);
+ }
+
}

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/om/jk/zpcciighgbeh2ofv
Default Alt Text
D7688.diff (1 KB)

Event Timeline