[李景山php]每天TP5-20170123|thinkphp5-Process.php-5

來源:互聯網
上載者:User

標籤:thinkphp5

    /**     * 開啟從底層過程擷取輸出和錯誤輸出。     * @return Process     * @throws \RuntimeException     */    public function enableOutput()    {// enableOutput        if ($this->isRunning()) {// 如果 運行            throw new \RuntimeException(‘Enabling output while the process is running is not possible.‘);        }        $this->outputDisabled = false;// 輸出 標誌位 禁止        return $this;// 返回 類本身    }    /**     * 輸出是否禁用     * @return bool     */    public function isOutputDisabled()// 返回 是否 isOutputDisabled 直接返回 當前結果    {        return $this->outputDisabled;    }    /**     * 擷取當前的輸出管道     * @return string     * @throws \LogicException     * @throws \LogicException     * @api     */    public function getOutput()// 擷取 當前的 輸出 管道    {        if ($this->outputDisabled) {// 如果 禁止 輸出            throw new \LogicException(‘Output has been disabled.‘);// logicException        }        $this->requireProcessIsStarted(__FUNCTION__);// 擷取進程 開始        $this->readPipes(false, ‘\\‘ === DS ? !$this->processInformation[‘running‘] : true);// 讀取管道資訊        return $this->stdout;// 返回輸出 資訊        // processInformation    }    /**     * 以增量方式返回的輸出結果。     * @return string     */    public function getIncrementalOutput()    {// 以增量方式返回的輸出結果        $this->requireProcessIsStarted(__FUNCTION__);// 開始進程        $data = $this->getOutput();// 擷取輸出資訊        $latest = substr($data, $this->incrementalOutputOffset);// 增量位置        if (false === $latest) {// 如果增量 為空白            return ‘‘;        }        $this->incrementalOutputOffset = strlen($data);// 標註下一次的 起始位置        return $latest;// 返回 增量 是個字串    }    /**     * 清空輸出     * @return Process     */    public function clearOutput()// 清空 輸出    {        $this->stdout                  = ‘‘;// 總的輸出 資料        $this->incrementalOutputOffset = 0;// 增量位置 初始化為0        return $this;// 返回 類本身    }    /**     * 返回當前的錯誤輸出的過程 (STDERR)。     * @return string     */    public function getErrorOutput()    {// 擷取錯誤輸出        if ($this->outputDisabled) {            throw new \LogicException(‘Output has been disabled.‘);        }        $this->requireProcessIsStarted(__FUNCTION__);// 開始程式        $this->readPipes(false, ‘\\‘ === DS ? !$this->processInformation[‘running‘] : true);// 讀取管道資訊        return $this->stderr;// 返回 錯誤字串    }    /**     * 以增量方式返回 errorOutput     * @return string     */    public function getIncrementalErrorOutput()    {// 增量方式 返回錯誤資訊        $this->requireProcessIsStarted(__FUNCTION__);        $data = $this->getErrorOutput();        $latest = substr($data, $this->incrementalErrorOutputOffset);        if (false === $latest) {            return ‘‘;        }        $this->incrementalErrorOutputOffset = strlen($data);        return $latest;    }// 同上的 普通訊息輸出    /**     * 清空 errorOutput     * @return Process     */    public function clearErrorOutput()    {        $this->stderr                       = ‘‘;        $this->incrementalErrorOutputOffset = 0;        return $this;    }// 清空 錯誤 資訊    /**     * 擷取退出碼     * @return null|int     */    public function getExitCode()    {// 擷取 退出碼        if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) {            throw new \RuntimeException(‘This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.‘);        }// 擷取退出碼        $this->updateStatus(false);//更新狀態        return $this->exitcode;// 退出    }    /**     * 擷取退出文本     * @return null|string     */    public function getExitCodeText()    {        if (null === $exitcode = $this->getExitCode()) {            return null;        }        return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : ‘Unknown error‘;    }// 擷取退出 文本提示    /**     * 檢查是否成功     * @return bool     */    public function isSuccessful()    {        return 0 === $this->getExitCode();    }// 如果正常退出 為0 就是 成功了    /**     * 是否未捕獲的訊號已被終止子進程     * @return bool     */    public function hasBeenSignaled()    {        $this->requireProcessIsTerminated(__FUNCTION__);        if ($this->isSigchildEnabled()) {            throw new \RuntimeException(‘This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.‘);        }        $this->updateStatus(false);        return $this->processInformation[‘signaled‘];    }


本文出自 “專註php 群號:414194301” 部落格,請務必保留此出處http://jingshanls.blog.51cto.com/3357095/1886084

[李景山php]每天TP5-20170123|thinkphp5-Process.php-5

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.