[李景山php]每天TP5-20170125|thinkphp5-Process.php-7

    /**
     * 获取输入
     * @return null|string
     */
    public function getInput()
    {
        return $this->input;
    }// 获取输入信息

    /**
     * 设置输入
     * @param mixed $input
     * @return self
     */
    public function setInput($input)
    {
        if ($this->isRunning()) {
            throw new \LogicException('Input can not be set while the process is running.');
        }

        $this->input = Utils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input);

        return $this;
    }// 属于信息 设置

    /**
     * 获取proc_open的选项
     * @return array
     */
    public function getOptions()
    {
        return $this->options;
    }// 获取 选项

    /**
     * 设置proc_open的选项
     * @param array $options
     * @return self
     */
    public function setOptions(array $options)
    {
        $this->options = $options;

        return $this;
    }// 设置选项,这个设置,有点唐突哦

    /**
     * 是否兼容windows
     * @return bool
     */
    public function getEnhanceWindowsCompatibility()
    {
        return $this->enhanceWindowsCompatibility;
    }// 我就是说这个是 windows 兼容的 情况,一般不兼容这个鬼东西

    /**
     * 设置是否兼容windows
     * @param bool $enhance
     * @return self
     */
    public function setEnhanceWindowsCompatibility($enhance)
    {
        $this->enhanceWindowsCompatibility = (bool)$enhance;

        return $this;
    }// 设置 是否兼容 windows

    /**
     * 返回是否 sigchild 兼容模式激活
     * @return bool
     */
    public function getEnhanceSigchildCompatibility()
    {
        return $this->enhanceSigchildCompatibility;
    }// 是否子进程模式 激活

    /**
     * 激活 sigchild 兼容性模式。
     * @param bool $enhance
     * @return self
     */
    public function setEnhanceSigchildCompatibility($enhance)
    {
        $this->enhanceSigchildCompatibility = (bool)$enhance;

        return $this;
    }// 激活它

    /**
     * 是否超时
     */
    public function checkTimeout()
    {// 是否超时
        if ($this->status !== self::STATUS_STARTED) {
            return;
        }// 类型

        if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
            $this->stop();
// 如果 时间 溢出
            throw new ProcessTimeoutException($this, ProcessTimeoutException::TYPE_GENERAL);
        }// 抛出异常

        if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
            $this->stop();

            throw new ProcessTimeoutException($this, ProcessTimeoutException::TYPE_IDLE);
        }// 抛出异常2
    }

    /**
     * 是否支持pty
     * @return bool
     */
    public static function isPtySupported()
    {// 是否支持 pty
        static $result;// 静态结果

        if (null !== $result) {// 有结果,就直接返回
            return $result;
        }

        if ('\\' === DS) {// 在 windows 下呢
            return $result = false;// 返回 错误信息
        }

        $proc = @proc_open('echo 1', [['pty'], ['pty'], ['pty']], $pipes);// 打开类似于管道方式
        if (is_resource($proc)) {// 如果是资源
            proc_close($proc);// 关闭资源

            return $result = true;
        }

        return $result = false;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值