Skip to content
This repository was archived by the owner on Feb 6, 2019. It is now read-only.

Repository files navigation

task

A PHP process forking and fork handling library.

Build Status

Install

$ composer require troublete/task

Usage

<?phprequire_once'/path/to/autoload.php';
usefunctionTask\{forkTask, checkSuccess};
$pid = forkTask(function () {
// do something that is only happening in the forked process
});
// continue work...checkSuccess($pid); // to check if the process finished with great success

API

Functions

forkTask($taskClosure, $arguments = [], $signalHandler = null)

Function to fork off a child process. Returns the pid of the forked off process if successfull, throws an Exception if forking was not possible.

Arguments
ArgumentTypeDescription
$taskClosurecallableClosure function that is only executed in the child process
$argumentsarrayArguments that are passed to the child process closure (optional)
$signalHandlercallableHandler for process signals (optional)

getProcessStatus($processId = null)

Function that returns that status of a forked child by process id. If provided process id is null it'll return 0.

Arguments
ArgumentTypeDescription
$processIdintId of the process to be checked

checkSuccess($processId = null)

Function that returns based on the process status if a process already finished with great success. If the return value of this is false it does not necessarily mean that the process failed though. Since this is a non blocking process check. It is just not successfully finished at the point of the check.

Arguments
ArgumentTypeDescription
$processIdintId of the process to be checked

closeTask($processId = null)

Function to close a forked process. Returns true if successfull.

Arguments
ArgumentTypeDescription
$processIdintId of the process to be checked

License

GPL-2.0 © Willi Eßer

About

A PHP process forking and fork handling library.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages