From ee7f35c3e4d36d85384d622baa2460543cabc135 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Thu, 9 Feb 2017 13:30:07 -0600 Subject: [PATCH] =?UTF-8?q?Another=20try=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Process.php | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/lib/Process.php b/lib/Process.php index f297df1..a066220 100644 --- a/lib/Process.php +++ b/lib/Process.php @@ -133,7 +133,7 @@ class Process { ]; if (\strncasecmp(\PHP_OS, "WIN", 3) === 0) { - $command = $this->command; + $command = '"' . $this->command . '; exit $LASTEXITCODE" & echo %ERRORLEVEL%'; } else { $command = \sprintf('(%s) 3>/dev/null; code=$?; echo $code >&3; exit $code', $this->command); } @@ -167,17 +167,6 @@ class Process { $this->stdout = $pipes[1]; $this->stderr = $pipes[2]; - if ($status["exitcode"] !== -1 && $status["exitcode"] !== false) { - $this->deferred->resolve($status["exitcode"]); - if (\is_resource($pipes[3])) { - \fclose($pipes[3]); - } - if (\is_resource($stdin)) { - \fclose($stdin); - } - return $deferred->promise(); - } - $this->running = true; $process = &$this->process; @@ -190,21 +179,10 @@ class Process { try { try { - if (\strncasecmp(\PHP_OS, "WIN", 3) === 0) { - $status = \proc_get_status($process); - if (!\is_array($status)) { - throw new ProcessException("Unable to get process status"); - } - $code = $status["exitcode"]; - } else { - if (!\is_resource($resource) || \feof($resource)) { - throw new ProcessException("Process ended unexpectedly"); - } - $code = \rtrim(@\stream_get_contents($resource)); - if (!\strlen($code) || !\is_numeric($code)) { - throw new ProcessException("Unable to read exit code"); - } + if (!\is_resource($resource) || \feof($resource)) { + throw new ProcessException("Process ended unexpectedly"); } + $code = \rtrim(@\stream_get_contents($resource)); } finally { if (\is_resource($resource)) { \fclose($resource);