ThinkPHP5


think\Process
library\think\Process.php at line 21

Class Process

Process

public class Process


Constant Summary
final static str

ERR

final static str

OUT

final static str

STATUS_READY

final static str

STATUS_STARTED

final static str

STATUS_TERMINATED

final static int

STDERR

final static int

STDIN

final static int

STDOUT

final static int

TIMEOUT_PRECISION

Field Summary
static array

$exitCodes

Constructor Summary
void

__construct(string commandline, string|null cwd, array|null env, string|null input, int|float|null timeout, array options)

构造方法

Method Summary
int

run(callback|null callback)

运行指令

self

mustRun(callable|null callback)

运行指令

void

start(callable|null callback)

启动进程并写到 STDIN 输入后返回。

Process

restart(callable|null callback)

重启进程

int

wait(callable|null callback)

等待要终止的进程

int|null

getPid()

获取PID

Process

signal(int signal)

将一个 POSIX 信号发送到进程中

Process

disableOutput()

禁用从底层过程获取输出和错误输出。

Process

enableOutput()

开启从底层过程获取输出和错误输出。

bool

isOutputDisabled()

输出是否禁用

string

getOutput()

获取当前的输出管道

string

getIncrementalOutput()

以增量方式返回的输出结果。

Process

clearOutput()

清空输出

string

getErrorOutput()

返回当前的错误输出的过程 (STDERR)。

string

getIncrementalErrorOutput()

以增量方式返回 errorOutput

Process

clearErrorOutput()

清空 errorOutput

null|int

getExitCode()

获取退出码

null|string

getExitCodeText()

获取退出文本

bool

isSuccessful()

检查是否成功

bool

hasBeenSignaled()

是否未捕获的信号已被终止子进程

int

getTermSignal()

返回导致子进程终止其执行的数。

bool

hasBeenStopped()

检查子进程信号是否已停止

int

getStopSignal()

返回导致子进程停止其执行的数。

bool

isRunning()

检查是否正在运行

bool

isStarted()

检查是否已开始

bool

isTerminated()

检查是否已终止

string

getStatus()

获取当前的状态

void

stop()

终止进程

void

addOutput(string line)

添加一行输出

void

addErrorOutput(string line)

添加一行错误输出

string

getCommandLine()

获取被执行的指令

self

setCommandLine(string commandline)

设置指令

float|null

getTimeout()

获取超时时间

float|null

getIdleTimeout()

获取idle超时时间

self

setTimeout(int|float|null timeout)

设置超时时间

self

setIdleTimeout(int|float|null timeout)

设置idle超时时间

self

setTty(bool tty)

设置TTY

bool

isTty()

检查是否是tty模式

self

setPty(bool bool)

设置pty模式

bool

isPty()

是否是pty模式

string|null

getWorkingDirectory()

获取工作目录

self

setWorkingDirectory(string cwd)

设置工作目录

array

getEnv()

获取环境变量

self

setEnv(array env)

设置环境变量

null|string

getInput()

获取输入

self

setInput(mixed input)

设置输入

array

getOptions()

获取proc_open的选项

self

setOptions(array options)

设置proc_open的选项

bool

getEnhanceWindowsCompatibility()

是否兼容windows

self

setEnhanceWindowsCompatibility(bool enhance)

设置是否兼容windows

bool

getEnhanceSigchildCompatibility()

返回是否 sigchild 兼容模式激活

self

setEnhanceSigchildCompatibility(bool enhance)

激活 sigchild 兼容性模式。

void

checkTimeout()

是否超时

static bool

isPtySupported()

是否支持pty

protected callable

buildCallback(callable|null callback)

建立 wait () 使用的回调。

protected void

updateStatus(bool blocking)

更新状态

protected bool

isSigchildEnabled()

是否开启 '--enable-sigchild'

Constant Detail

library\think\Process.php at line 24

ERR

public final static str ERR = 'err'

library\think\Process.php at line 25

OUT

public final static str OUT = 'out'

library\think\Process.php at line 27

STATUS_READY

public final static str STATUS_READY = 'ready'

library\think\Process.php at line 28

STATUS_STARTED

public final static str STATUS_STARTED = 'started'

library\think\Process.php at line 29

STATUS_TERMINATED

public final static str STATUS_TERMINATED = 'terminated'

library\think\Process.php at line 33

STDERR

public final static int STDERR = 2

library\think\Process.php at line 31

STDIN

public final static int STDIN = 0

library\think\Process.php at line 32

STDOUT

public final static int STDOUT = 1

library\think\Process.php at line 35

TIMEOUT_PRECISION

public final static int TIMEOUT_PRECISION = 0.2

Field Detail

library\think\Process.php at line 74

exitCodes

public static array $exitCodes = [ 0 => 'OK'


Constructor Detail

library\think\Process.php at line 87

__construct

public void __construct(string commandline, string|null cwd, array|null env, string|null input, int|float|null timeout, array options)

构造方法

Parameters:
commandline - 指令
cwd - 工作目录
env - 环境变量
input - 输入
timeout - 超时时间
options - proc_open的选项
Throws:
\RuntimeException
Api.

Method Detail

library\think\Process.php at line 130

run

public int run(callback|null callback)

运行指令


library\think\Process.php at line 144

mustRun

public self mustRun(callable|null callback)

运行指令

Throws:
\RuntimeException
ProcessFailedException

library\think\Process.php at line 164

start

public void start(callable|null callback)

启动进程并写到 STDIN 输入后返回。

Throws:
\RuntimeException
\RuntimeException
\LogicException

library\think\Process.php at line 214

restart

public Process restart(callable|null callback)

重启进程

Throws:
\RuntimeException
\RuntimeException

library\think\Process.php at line 231

wait

public int wait(callable|null callback)

等待要终止的进程


library\think\Process.php at line 263

getPid

public int|null getPid()

获取PID

Throws:
\RuntimeException

library\think\Process.php at line 279

signal

public Process signal(int signal)

将一个 POSIX 信号发送到进程中


library\think\Process.php at line 290

disableOutput

public Process disableOutput()

禁用从底层过程获取输出和错误输出。


library\think\Process.php at line 309

enableOutput

public Process enableOutput()

开启从底层过程获取输出和错误输出。

Throws:
\RuntimeException

library\think\Process.php at line 324

isOutputDisabled

public bool isOutputDisabled()

输出是否禁用


library\think\Process.php at line 336

getOutput

public string getOutput()

获取当前的输出管道

Throws:
\LogicException
\LogicException
Api.

library\think\Process.php at line 353

getIncrementalOutput

public string getIncrementalOutput()

以增量方式返回的输出结果。


library\think\Process.php at line 374

clearOutput

public Process clearOutput()

清空输出


library\think\Process.php at line 386

getErrorOutput

public string getErrorOutput()

返回当前的错误输出的过程 (STDERR)。


library\think\Process.php at line 403

getIncrementalErrorOutput

public string getIncrementalErrorOutput()

以增量方式返回 errorOutput


library\think\Process.php at line 424

clearErrorOutput

public Process clearErrorOutput()

清空 errorOutput


library\think\Process.php at line 436

getExitCode

public null|int getExitCode()

获取退出码


library\think\Process.php at line 451

getExitCodeText

public null|string getExitCodeText()

获取退出文本


library\think\Process.php at line 464

isSuccessful

public bool isSuccessful()

检查是否成功


library\think\Process.php at line 473

hasBeenSignaled

public bool hasBeenSignaled()

是否未捕获的信号已被终止子进程


library\think\Process.php at line 490

getTermSignal

public int getTermSignal()

返回导致子进程终止其执行的数。


library\think\Process.php at line 507

hasBeenStopped

public bool hasBeenStopped()

检查子进程信号是否已停止


library\think\Process.php at line 520

getStopSignal

public int getStopSignal()

返回导致子进程停止其执行的数。


library\think\Process.php at line 533

isRunning

public bool isRunning()

检查是否正在运行


library\think\Process.php at line 548

isStarted

public bool isStarted()

检查是否已开始


library\think\Process.php at line 557

isTerminated

public bool isTerminated()

检查是否已终止


library\think\Process.php at line 568

getStatus

public string getStatus()

获取当前的状态


library\think\Process.php at line 578

stop

public void stop()

终止进程


library\think\Process.php at line 608

addOutput

public void addOutput(string line)

添加一行输出


library\think\Process.php at line 618

addErrorOutput

public void addErrorOutput(string line)

添加一行错误输出


library\think\Process.php at line 628

getCommandLine

public string getCommandLine()

获取被执行的指令


library\think\Process.php at line 638

setCommandLine

public self setCommandLine(string commandline)

设置指令


library\think\Process.php at line 649

getTimeout

public float|null getTimeout()

获取超时时间


library\think\Process.php at line 658

getIdleTimeout

public float|null getIdleTimeout()

获取idle超时时间


library\think\Process.php at line 668

setTimeout

public self setTimeout(int|float|null timeout)

设置超时时间


library\think\Process.php at line 680

setIdleTimeout

public self setIdleTimeout(int|float|null timeout)

设置idle超时时间


library\think\Process.php at line 696

setTty

public self setTty(bool tty)

设置TTY


library\think\Process.php at line 714

isTty

public bool isTty()

检查是否是tty模式


library\think\Process.php at line 724

setPty

public self setPty(bool bool)

设置pty模式


library\think\Process.php at line 735

isPty

public bool isPty()

是否是pty模式


library\think\Process.php at line 744

getWorkingDirectory

public string|null getWorkingDirectory()

获取工作目录


library\think\Process.php at line 758

setWorkingDirectory

public self setWorkingDirectory(string cwd)

设置工作目录


library\think\Process.php at line 769

getEnv

public array getEnv()

获取环境变量


library\think\Process.php at line 779

setEnv

public self setEnv(array env)

设置环境变量


library\think\Process.php at line 797

getInput

public null|string getInput()

获取输入


library\think\Process.php at line 807

setInput

public self setInput(mixed input)

设置输入


library\think\Process.php at line 822

getOptions

public array getOptions()

获取proc_open的选项


library\think\Process.php at line 832

setOptions

public self setOptions(array options)

设置proc_open的选项


library\think\Process.php at line 843

getEnhanceWindowsCompatibility

public bool getEnhanceWindowsCompatibility()

是否兼容windows


library\think\Process.php at line 853

setEnhanceWindowsCompatibility

public self setEnhanceWindowsCompatibility(bool enhance)

设置是否兼容windows


library\think\Process.php at line 864

getEnhanceSigchildCompatibility

public bool getEnhanceSigchildCompatibility()

返回是否 sigchild 兼容模式激活


library\think\Process.php at line 874

setEnhanceSigchildCompatibility

public self setEnhanceSigchildCompatibility(bool enhance)

激活 sigchild 兼容性模式。


library\think\Process.php at line 884

checkTimeout

public void checkTimeout()

是否超时


library\think\Process.php at line 907

isPtySupported

public static bool isPtySupported()

是否支持pty


library\think\Process.php at line 957

buildCallback

protected callable buildCallback(callable|null callback)

建立 wait () 使用的回调。


library\think\Process.php at line 979

updateStatus

protected void updateStatus(bool blocking)

更新状态


library\think\Process.php at line 999

isSigchildEnabled

protected bool isSigchildEnabled()

是否开启 '--enable-sigchild'


ThinkPHP5