PHP Class think\Process

Afficher le fichier Open project: top-think/framework Class Usage Examples

Méthodes publiques

Свойство Type Description
$exitCodes array

Méthodes publiques

Méthode Description
__clone ( )
__construct ( string $commandline, string | null $cwd = null, array $env = null, string | null $input = null, integer | float | null $timeout = 60, array $options = [] ) 构造方法
__destruct ( )
addErrorOutput ( string $line ) 添加一行错误输出
addOutput ( string $line ) 添加一行输出
checkTimeout ( ) 是否超时
clearErrorOutput ( ) : Process 清空 errorOutput
clearOutput ( ) : Process 清空输出
disableOutput ( ) : Process 禁用从底层过程获取输出和错误输出。
enableOutput ( ) : Process 开启从底层过程获取输出和错误输出。
getCommandLine ( ) : string 获取被执行的指令
getEnhanceSigchildCompatibility ( ) : boolean 返回是否 sigchild 兼容模式激活
getEnhanceWindowsCompatibility ( ) : boolean 是否兼容windows
getEnv ( ) : array 获取环境变量
getErrorOutput ( ) : string 返回当前的错误输出的过程 (STDERR)。
getExitCode ( ) : null | integer 获取退出码
getExitCodeText ( ) : null | string 获取退出文本
getIdleTimeout ( ) : float | null 获取idle超时时间
getIncrementalErrorOutput ( ) : string 以增量方式返回 errorOutput
getIncrementalOutput ( ) : string 以增量方式返回的输出结果。
getInput ( ) : null | string 获取输入
getOptions ( ) : array 获取proc_open的选项
getOutput ( ) : string 获取当前的输出管道
getPid ( ) : integer | null 获取PID
getStatus ( ) : string 获取当前的状态
getStopSignal ( ) : integer 返回导致子进程停止其执行的数。
getTermSignal ( ) : integer 返回导致子进程终止其执行的数。
getTimeout ( ) : float | null 获取超时时间
getWorkingDirectory ( ) : string | null 获取工作目录
hasBeenSignaled ( ) : boolean 是否未捕获的信号已被终止子进程
hasBeenStopped ( ) : boolean 检查子进程信号是否已停止
isOutputDisabled ( ) : boolean 输出是否禁用
isPty ( ) : boolean 是否是pty模式
isPtySupported ( ) : boolean 是否支持pty
isRunning ( ) : boolean 检查是否正在运行
isStarted ( ) : boolean 检查是否已开始
isSuccessful ( ) : boolean 检查是否成功
isTerminated ( ) : boolean 检查是否已终止
isTty ( ) : boolean 检查是否是tty模式
mustRun ( callable | null $callback = null ) : self 运行指令
restart ( callable | null $callback = null ) : Process 重启进程
run ( callback | null $callback = null ) : integer 运行指令
setCommandLine ( string $commandline ) : self 设置指令
setEnhanceSigchildCompatibility ( boolean $enhance ) : self 激活 sigchild 兼容性模式。
setEnhanceWindowsCompatibility ( boolean $enhance ) : self 设置是否兼容windows
setEnv ( array $env ) : self 设置环境变量
setIdleTimeout ( integer | float | null $timeout ) : self 设置idle超时时间
setInput ( mixed $input ) : self 设置输入
setOptions ( array $options ) : self 设置proc_open的选项
setPty ( boolean $bool ) : self 设置pty模式
setTimeout ( integer | float | null $timeout ) : self 设置超时时间
setTty ( boolean $tty ) : self 设置TTY
setWorkingDirectory ( string $cwd ) : self 设置工作目录
signal ( integer $signal ) : Process 将一个 POSIX 信号发送到进程中
start ( callable | null $callback = null ) 启动进程并写到 STDIN 输入后返回。
stop ( ) 终止进程
wait ( callable | null $callback = null ) : integer 等待要终止的进程

Méthodes protégées

Méthode Description
buildCallback ( callable | null $callback ) : callable 建立 wait () 使用的回调。
isSigchildEnabled ( ) : boolean 是否开启 '--enable-sigchild'
updateStatus ( boolean $blocking ) 更新状态

Private Methods

Méthode Description
captureExitCode ( ) 捕获退出码
close ( ) : integer 关闭资源
doSignal ( integer $signal, boolean $throwException ) : boolean 将一个 POSIX 信号发送到进程中。
getDescriptors ( ) : array 创建所需的 proc_open 的描述符
readPipes ( boolean $blocking, boolean $close ) 读取pipes
requireProcessIsStarted ( string $functionName ) 确保进程已经开启
requireProcessIsTerminated ( string $functionName ) 确保进程已经终止
resetProcessData ( ) 重置数据
validateTimeout ( integer | float | null $timeout ) : float | null 验证是否超时

Method Details

__clone() public méthode

public __clone ( )

__construct() public méthode

构造方法
public __construct ( string $commandline, string | null $cwd = null, array $env = null, string | null $input = null, integer | float | null $timeout = 60, array $options = [] )
$commandline string 指令
$cwd string | null 工作目录
$env array 环境变量
$input string | null 输入
$timeout integer | float | null 超时时间
$options array proc_open的选项

__destruct() public méthode

public __destruct ( )

addErrorOutput() public méthode

添加一行错误输出
public addErrorOutput ( string $line )
$line string

addOutput() public méthode

添加一行输出
public addOutput ( string $line )
$line string

buildCallback() protected méthode

建立 wait () 使用的回调。
protected buildCallback ( callable | null $callback ) : callable
$callback callable | null
Résultat callable

checkTimeout() public méthode

是否超时
public checkTimeout ( )

clearErrorOutput() public méthode

清空 errorOutput
public clearErrorOutput ( ) : Process
Résultat Process

clearOutput() public méthode

清空输出
public clearOutput ( ) : Process
Résultat Process

disableOutput() public méthode

禁用从底层过程获取输出和错误输出。
public disableOutput ( ) : Process
Résultat Process

enableOutput() public méthode

开启从底层过程获取输出和错误输出。
public enableOutput ( ) : Process
Résultat Process

getCommandLine() public méthode

获取被执行的指令
public getCommandLine ( ) : string
Résultat string

getEnhanceSigchildCompatibility() public méthode

返回是否 sigchild 兼容模式激活

getEnhanceWindowsCompatibility() public méthode

是否兼容windows

getEnv() public méthode

获取环境变量
public getEnv ( ) : array
Résultat array

getErrorOutput() public méthode

返回当前的错误输出的过程 (STDERR)。
public getErrorOutput ( ) : string
Résultat string

getExitCode() public méthode

获取退出码
public getExitCode ( ) : null | integer
Résultat null | integer

getExitCodeText() public méthode

获取退出文本
public getExitCodeText ( ) : null | string
Résultat null | string

getIdleTimeout() public méthode

获取idle超时时间
public getIdleTimeout ( ) : float | null
Résultat float | null

getIncrementalErrorOutput() public méthode

以增量方式返回 errorOutput
public getIncrementalErrorOutput ( ) : string
Résultat string

getIncrementalOutput() public méthode

以增量方式返回的输出结果。
public getIncrementalOutput ( ) : string
Résultat string

getInput() public méthode

获取输入
public getInput ( ) : null | string
Résultat null | string

getOptions() public méthode

获取proc_open的选项
public getOptions ( ) : array
Résultat array

getOutput() public méthode

获取当前的输出管道
public getOutput ( ) : string
Résultat string

getPid() public méthode

获取PID
public getPid ( ) : integer | null
Résultat integer | null

getStatus() public méthode

获取当前的状态
public getStatus ( ) : string
Résultat string

getStopSignal() public méthode

返回导致子进程停止其执行的数。
public getStopSignal ( ) : integer
Résultat integer

getTermSignal() public méthode

返回导致子进程终止其执行的数。
public getTermSignal ( ) : integer
Résultat integer

getTimeout() public méthode

获取超时时间
public getTimeout ( ) : float | null
Résultat float | null

getWorkingDirectory() public méthode

获取工作目录
public getWorkingDirectory ( ) : string | null
Résultat string | null

hasBeenSignaled() public méthode

是否未捕获的信号已被终止子进程
public hasBeenSignaled ( ) : boolean
Résultat boolean

hasBeenStopped() public méthode

检查子进程信号是否已停止
public hasBeenStopped ( ) : boolean
Résultat boolean

isOutputDisabled() public méthode

输出是否禁用
public isOutputDisabled ( ) : boolean
Résultat boolean

isPty() public méthode

是否是pty模式
public isPty ( ) : boolean
Résultat boolean

isPtySupported() public static méthode

是否支持pty
public static isPtySupported ( ) : boolean
Résultat boolean

isRunning() public méthode

检查是否正在运行
public isRunning ( ) : boolean
Résultat boolean

isSigchildEnabled() protected méthode

是否开启 '--enable-sigchild'
protected isSigchildEnabled ( ) : boolean
Résultat boolean

isStarted() public méthode

检查是否已开始
public isStarted ( ) : boolean
Résultat boolean

isSuccessful() public méthode

检查是否成功
public isSuccessful ( ) : boolean
Résultat boolean

isTerminated() public méthode

检查是否已终止
public isTerminated ( ) : boolean
Résultat boolean

isTty() public méthode

检查是否是tty模式
public isTty ( ) : boolean
Résultat boolean

mustRun() public méthode

运行指令
public mustRun ( callable | null $callback = null ) : self
$callback callable | null
Résultat self

restart() public méthode

重启进程
public restart ( callable | null $callback = null ) : Process
$callback callable | null
Résultat Process

run() public méthode

运行指令
public run ( callback | null $callback = null ) : integer
$callback callback | null
Résultat integer

setCommandLine() public méthode

设置指令
public setCommandLine ( string $commandline ) : self
$commandline string
Résultat self

setEnhanceSigchildCompatibility() public méthode

激活 sigchild 兼容性模式。
public setEnhanceSigchildCompatibility ( boolean $enhance ) : self
$enhance boolean
Résultat self

setEnhanceWindowsCompatibility() public méthode

设置是否兼容windows
public setEnhanceWindowsCompatibility ( boolean $enhance ) : self
$enhance boolean
Résultat self

setEnv() public méthode

设置环境变量
public setEnv ( array $env ) : self
$env array
Résultat self

setIdleTimeout() public méthode

设置idle超时时间
public setIdleTimeout ( integer | float | null $timeout ) : self
$timeout integer | float | null
Résultat self

setInput() public méthode

设置输入
public setInput ( mixed $input ) : self
$input mixed
Résultat self

setOptions() public méthode

设置proc_open的选项
public setOptions ( array $options ) : self
$options array
Résultat self

setPty() public méthode

设置pty模式
public setPty ( boolean $bool ) : self
$bool boolean
Résultat self

setTimeout() public méthode

设置超时时间
public setTimeout ( integer | float | null $timeout ) : self
$timeout integer | float | null
Résultat self

setTty() public méthode

设置TTY
public setTty ( boolean $tty ) : self
$tty boolean
Résultat self

setWorkingDirectory() public méthode

设置工作目录
public setWorkingDirectory ( string $cwd ) : self
$cwd string
Résultat self

signal() public méthode

将一个 POSIX 信号发送到进程中
public signal ( integer $signal ) : Process
$signal integer
Résultat Process

start() public méthode

启动进程并写到 STDIN 输入后返回。
public start ( callable | null $callback = null )
$callback callable | null

stop() public méthode

终止进程
public stop ( )

updateStatus() protected méthode

更新状态
protected updateStatus ( boolean $blocking )
$blocking boolean

wait() public méthode

等待要终止的进程
public wait ( callable | null $callback = null ) : integer
$callback callable | null
Résultat integer

Property Details

$exitCodes public_oe static_oe property

public static array $exitCodes
Résultat array