PHP Class Jenner\SimpleFork\Process

Mostrar archivo Open project: huyanping/simple-fork-php Class Usage Examples

Protected Properties

Property Type Description
$callbacks array
$errmsg error message
$errno error code
$if_signal boolean
$name custom process name
$pid integer
$runnable Jenner\SimpleFork\Runnable | callable
$running boolean
$signal_handlers signal handlers
$started if the process is started
$stop_signal the signal which made the process stop
$term_signal the signal which made the process terminate

Public Methods

Method Description
__construct ( string $execution = null, null $name = null )
errmsg ( ) : string get pcntl errmsg
errno ( ) : integer get pcntl errno
getPid ( ) : integer get pid
ifSignal ( )
isRunning ( ) : boolean if the process is running
isStarted ( ) : boolean if the process is started
isStopped ( ) : boolean if the process is stopped
name ( string | null $name = null ) : mixed get or set name
registerSignalHandler ( $signal, callable $handler ) register sub process signal handler, when the sub process start, the handlers will be registered
run ( ) you should overwrite this function if you do not use the Runnable or callback.
shutdown ( boolean | true $block = true, integer $signal = SIGTERM ) kill self
start ( ) : string start the sub process and run the callback
wait ( boolean | true $block = true, integer $sleep = 100000 ) waiting for the sub process exit

Protected Methods

Method Description
getCallable ( ) : array | callable | null get sub process callback
initStatus ( ) init process status
signal ( ) register signal SIGTERM handler, when the parent process call shutdown and use the default signal, this handler will be triggered
updateStatus ( boolean $block = false ) update the process status

Method Details

__construct() public method

public __construct ( string $execution = null, null $name = null )
$execution string it can be a Runnable object, callback function or null
$name null process name,you can manager the process by it's name.

errmsg() public method

get pcntl errmsg
public errmsg ( ) : string
return string

errno() public method

get pcntl errno
public errno ( ) : integer
return integer

getCallable() protected method

get sub process callback
protected getCallable ( ) : array | callable | null
return array | callable | null

getPid() public method

get pid
public getPid ( ) : integer
return integer

ifSignal() public method

public ifSignal ( )

initStatus() protected method

init process status
protected initStatus ( )

isRunning() public method

if the process is running
public isRunning ( ) : boolean
return boolean

isStarted() public method

if the process is started
public isStarted ( ) : boolean
return boolean

isStopped() public method

if the process is stopped
public isStopped ( ) : boolean
return boolean

name() public method

get or set name
public name ( string | null $name = null ) : mixed
$name string | null
return mixed

registerSignalHandler() public method

register sub process signal handler, when the sub process start, the handlers will be registered
public registerSignalHandler ( $signal, callable $handler )
$signal
$handler callable

run() public method

you should overwrite this function if you do not use the Runnable or callback.
public run ( )

shutdown() public method

kill self
public shutdown ( boolean | true $block = true, integer $signal = SIGTERM )
$block boolean | true
$signal integer

signal() protected method

register signal SIGTERM handler, when the parent process call shutdown and use the default signal, this handler will be triggered
protected signal ( )

start() public method

start the sub process and run the callback
public start ( ) : string
return string pid

updateStatus() protected method

update the process status
protected updateStatus ( boolean $block = false )
$block boolean

wait() public method

waiting for the sub process exit
public wait ( boolean | true $block = true, integer $sleep = 100000 )
$block boolean | true if block the process
$sleep integer default 0.1s check sub process status every $sleep milliseconds.

Property Details

$callbacks protected_oe property

protected array $callbacks
return array

$errmsg protected_oe property

error message
protected $errmsg

$errno protected_oe property

error code
protected $errno

$if_signal protected_oe property

protected bool $if_signal
return boolean

$name protected_oe property

custom process name
protected $name

$pid protected_oe property

protected int $pid
return integer

$runnable protected_oe property

protected Runnable,Jenner\SimpleFork|callable $runnable
return Jenner\SimpleFork\Runnable | callable

$running protected_oe property

protected bool $running
return boolean

$signal_handlers protected_oe property

signal handlers
protected $signal_handlers

$started protected_oe property

if the process is started
protected $started

$stop_signal protected_oe property

the signal which made the process stop
protected $stop_signal

$term_signal protected_oe property

the signal which made the process terminate
protected $term_signal