I'm trying to create a daemon process that handles several child threads. But the child thread doesn't seem to send the signal back to the parent to call the function. i have tried to take it out of the class and make it a standard function but that doesn't seem to help either.
class Daemon {
public function __construct() {
$set = pcntl_signal(SIGCHLD, array($this, 'childSignalHandler'));
$pid = pcntl_fork();
if ($pid == -1) {
echo 'could not fork';
} elseif ($pid) {
// parent
sleep(20);
// this would keep running and spawn other children from time to time
} else {
// child
sleep(5);
// should call childSignalHandler() in parent
}
}
public function childSignalHandler($pid) {
echo 'child is dead';
}
}
new Daemon();