/** * Reads pipes, executes callback. * * @param bool $blocking Whether to use blocking calls or not. * @param bool $close Whether to close file handles or not. */ private function readPipes($blocking, $close) { $result = $this->processPipes->readAndWrite($blocking, $close); foreach ($result as $type => $data) { if (3 == $type) { $this->fallbackExitcode = (int) $data; } else { call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data); } } }
/** * Reads pipes, executes callback. * * @param bool $blocking Whether to use blocking calls or not. * @param bool $close Whether to close file handles or not. */ private function readPipes($blocking, $close) { $result = $this->processPipes->readAndWrite($blocking, $close); $callback = $this->callback; foreach ($result as $type => $data) { if (3 !== $type) { $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); } elseif (!isset($this->fallbackStatus['signaled'])) { $this->fallbackStatus['exitcode'] = (int) $data; } } }
/** * Reads pipes, executes callback. * * @param bool $blocking Whether to use blocking calls or not. * @param bool $close Whether to close file handles or not. */ private function readPipes($blocking, $close) { $result = $this->processPipes->readAndWrite($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] && !isset($this->fallbackStatus['signaled'])) { $this->fallbackStatus['exitcode'] = (int) substr($data, 1); } } } else { $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); } } }