#### Process
~~~
/**
* 構造方法
* @param string $commandline 指令
* @param string|null $cwd 工作目錄
* @param array|null $env 環境變量
* @param string|null $input 輸入
* @param int|float|null $timeout 超時時間
* @param array $options proc_open的選項
* @throws \RuntimeException
* @api
*/
$process = new Process($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = []);
// 停止
$process->__destruct();
// 克隆
$process->__clone();
/**
* 運行指令
* @param callback|null $callback
* @return int
*/
$process->run($callback = null);
/**
* 運行指令
* @param callable|null $callback
* @return self
* @throws \RuntimeException
* @throws ProcessFailedException
*/
$process->mustRun($callback = null);
/**
* 啟動進程并寫到 STDIN 輸入后返回。
* @param callable|null $callback
* @throws \RuntimeException
* @throws \RuntimeException
* @throws \LogicException
*/
$process->start($callback = null);
/**
* 重啟進程
* @param callable|null $callback
* @return Process
* @throws \RuntimeException
* @throws \RuntimeException
*/
$process->restart($callback = null);
/**
* 等待要終止的進程
* @param callable|null $callback
* @return int
*/
$process->wait($callback = null);
/**
* 獲取PID
* @return int|null
* @throws \RuntimeException
*/
$process->getPid();
/**
* 將一個 POSIX 信號發送到進程中
* @param int $signal
* @return Process
*/
$process->signal($signal);
// 禁用從底層過程獲取輸出和錯誤輸出。
$process->disableOutput();
// 開啟從底層過程獲取輸出和錯誤輸出。
$process->enableOutput();
// 輸出是否禁用
$process->isOutputDisabled();
/**
* 獲取當前的輸出管道
* @return string
* @throws \LogicException
* @throws \LogicException
* @api
*/
$process->getOutput();
// 以增量方式返回的輸出結果。
$process->getIncrementalOutput();
// 清空輸出
$process->clearOutput();
// 返回當前的錯誤輸出的過程 (STDERR)。
$process->getErrorOutput();
// 以增量方式返回 errorOutput
$process->getIncrementalErrorOutput();
// 清空 errorOutput
$process->clearErrorOutput();
/**
* 獲取退出碼
* @return null|int
*/
$process->getExitCode();
/**
* 獲取退出文本
* @return null|string
*/
$process->getExitCodeText();
// 檢查是否成功
$process->isSuccessful();
// 是否未捕獲的信號已被終止子進程
$process->hasBeenSignaled();
// 返回導致子進程終止其執行的數。
$process->getTermSignal();
// 檢查是否正在運行
$process->isRunning();
// 檢查是否已開始
$process->isStarted();
// 檢查是否已終止
$process->isTerminated();
// 獲取當前的狀態
$process->getStatus();
// 終止進程
$process->stop();
// 添加一行輸出
$process->addOutput($line);
// 添加一行錯誤輸出
$process->addErrorOutput($line);
// 獲取被執行的指令
$process->getCommandLine();
// 設置指令
$process->setCommandLine($commandline);
// 獲取超時時間
$process->getTimeout();
// 獲取idle超時時間
$process->getIdleTimeout();
// 設置超時時間
$process->setTimeout($timeout);
// 設置idle超時時間
$process->setIdleTimeout($timeout);
// 設置TTY
$process->setTty($tty);
// 檢查是否是tty模式
$process->isTty();
// 設置pty模式
$process->setPty($bool);
// 是否是pty模式
$process->isPty();
// 獲取工作目錄
$process->getWorkingDirectory();
// 設置工作目錄
$process->setWorkingDirectory($cwd);
// 獲取環境變量
$process->getEnv();
// 設置環境變量
$process->setEnv(array $env);
// 獲取輸入
$process->getInput();
// 設置輸入
$process->setInput($input);
// 獲取proc_open的選項
$process->getOptions();
// 設置proc_open的選項
$process->setOptions(array $options);
// 是否兼容windows
$process->getEnhanceWindowsCompatibility();
// 設置是否兼容windows
$process->setEnhanceWindowsCompatibility($enhance);
// 返回是否 sigchild 兼容模式激活
$process->getEnhanceSigchildCompatibility();
// 激活 sigchild 兼容性模式。
$process->setEnhanceSigchildCompatibility($enhance);
// 是否超時
$process->checkTimeout();
// 是否支持pty
Process::isPtySupported();
// 創建所需的 proc_open 的描述符
$this->getDescriptors();
// 建立 wait () 使用的回調。
$this->buildCallback($callback);
// 更新狀態
$this->updateStatus($blocking);
// 是否開啟 '--enable-sigchild'
$this->isSigchildEnabled();
// 驗證是否超時
$this->validateTimeout($timeout);
// 讀取pipes
$this->readPipes($blocking, $close);
// 捕獲退出碼
$this->captureExitCode();
/**
* 關閉資源
* @return int 退出碼
*/
$this->close();
// 重置數據
$this->resetProcessData();
// 將一個 POSIX 信號發送到進程中。
$this->doSignal($signal, $throwException);
// 確保進程已經開啟
$this->requireProcessIsStarted($functionName);
// 確保進程已經終止
$this->requireProcessIsTerminated($functionName);
~~~