\Cocur\BackgroundProcessBackgroundProcess

BackgroundProcess.

Runs a process in the background.

Summary

Methods
Properties
Constants
__construct()
run()
isRunning()
stop()
getPid()
createFromPID()
No public properties found
OS_WINDOWS
OS_NIX
OS_OTHER
setPid()
getOS()
checkSupportingOS()
$serverOS
N/A
No private methods found
$command
$pid
N/A

Constants

OS_WINDOWS

OS_WINDOWS = 1

OS_NIX

OS_NIX = 2

OS_OTHER

OS_OTHER = 3

Properties

$serverOS

$serverOS : integer

Type

integer

$command

$command : string

Type

string

$pid

$pid : integer

Type

integer

Methods

__construct()

__construct(string  $command = null) 

Parameters

string $command

The command to execute

run()

run(string  $outputFile = '/dev/null', boolean  $append = false) 

Runs the command in a background process.

Parameters

string $outputFile

File to write the output of the process to; defaults to /dev/null currently $outputFile has no effect when used in conjunction with a Windows server

boolean $append
  • set to true if output should be appended to $outputfile

isRunning()

isRunning() : boolean

Returns if the process is currently running.

Returns

boolean —

TRUE if the process is running, FALSE if not.

stop()

stop() : boolean

Stops the process.

Returns

boolean —

true if the processes was stopped, false otherwise.

getPid()

getPid() : integer

Returns the ID of the process.

Returns

integer —

The ID of the process

createFromPID()

createFromPID(integer  $pid) : \Cocur\BackgroundProcess\Cocur\BackgroundProcess\BackgroundProcess

Parameters

integer $pid

PID of process to resume

Returns

\Cocur\BackgroundProcess\Cocur\BackgroundProcess\BackgroundProcess

setPid()

setPid(  $pid) 

Set the process id.

Parameters

$pid

getOS()

getOS() : integer

Returns

integer

checkSupportingOS()

checkSupportingOS(string  $message) 

Parameters

string $message

Exception message if the OS is not supported

Throws

\RuntimeException

if the operating system is not supported by Cocur\BackgroundProcess