From 088fcfe0934ad1fbe1c672c5f713f2440e86e6b4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 23 Dec 2015 10:10:11 +0100 Subject: [PATCH] [Process] Fix the fix for --enable-sigchild php --- src/Symfony/Component/Process/Process.php | 33 +++---------------- .../Component/Process/Tests/ProcessTest.php | 2 +- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 636ddb951344..b2af092747f8 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -65,14 +65,6 @@ class Process private $latestSignal; private static $sigchild; - private static $posixSignals = array( - 1, // SIGHUP - 2, // SIGINT - 3, // SIGQUIT - 6, // SIGABRT - 14, // SIGALRM - 15, // SIGTERM - ); /** * Exit codes translation table. @@ -246,14 +238,9 @@ public function start($callback = null) // last exit code is output on the fourth pipe and caught to work around --enable-sigchild $descriptors[3] = array('pipe', 'w'); - $commandline = ''; - foreach (self::$posixSignals as $s) { - $commandline .= "trap 'echo s$s >&3' $s;"; - } - // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input - $commandline .= '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; - $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code'; + $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; + $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code'; // Workaround for the bug, when PTS functionality is enabled. // @see : https://bugs.php.net/69442 @@ -1086,19 +1073,9 @@ private function readPipes($blocking, $close) $callback = $this->callback; foreach ($result as $type => $data) { if (3 === $type) { - foreach (explode("\n", substr($data, 0, -1)) as $data) { - if ('p' === $data[0]) { - $this->fallbackStatus['pid'] = (int) substr($data, 1); - } elseif ('s' === $data[0]) { - $this->fallbackStatus['signaled'] = true; - $this->fallbackStatus['exitcode'] = -1; - $this->fallbackStatus['termsig'] = (int) substr($data, 1); - } elseif ('x' === $data[0]) { - $this->fallbackStatus['running'] = false; - if (!isset($this->fallbackStatus['signaled'])) { - $this->fallbackStatus['exitcode'] = (int) substr($data, 1); - } - } + $this->fallbackStatus['running'] = false; + if (!isset($this->fallbackStatus['signaled'])) { + $this->fallbackStatus['exitcode'] = (int) $data; } } else { $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index d64eb07d30b0..2bfb2441e117 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -689,7 +689,7 @@ public function testRunProcessWithTimeout() if ('\\' !== DIRECTORY_SEPARATOR) { // On Windows, timers are too transient - $maxDuration = $timeout + Process::TIMEOUT_PRECISION; + $maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION; $this->assertLessThan($maxDuration, $duration); }