Tuner
Tuner

Reputation: 69

PHP library to ease creation of processes (fork)

Do you know any library that eases work with processes, signal sending etc? Thank you in advance!

EDIT: We're doing some data loading from external sources in PHP daemon. We want to split PHP process to have:

Upvotes: 2

Views: 1520

Answers (2)

rdo
rdo

Reputation: 3982

You can use process control library, but it works only on linux.

For fork purposes it contains pcntl_fork function. Example:

$pid = pcntl_fork();
if ($pid == -1) {
     die('could not fork');
} else if ($pid) {
     // we are the parent
     pcntl_wait($status); //Protect against Zombie children
} else {
     // we are the child
}

UPD: if I correct understand your goals you design your application without forking of processes. You can use two daemons where first daemon will process data source and add it to queue. The second daemon will track the queue and process it.

P.s. As I know php can not fork processes on windows platforms. Also for additional you can use POSIX function in php.

Upvotes: 2

Maerlyn
Maerlyn

Reputation: 34107

You may want to check out Spork, it's designed to ease forking and background processing in php.

It's pretty new (announced just 3 days ago), but worth a try.

Upvotes: 3

Related Questions