This is how it is done...
make sure you do NOT run this from a browser as it is very bad to fork and apache at the same time.
you also need pcntl compiled into PHP
change SIGUSR1 to what ever signel you want to capture
#!/usr/local/bin/php -q
<?php
set_time_limit (0);
ob_implicit_flush ();
pcntl_signal(SIGUSR1, "sig_handler");
if ($pid = pcntl_fork()) {
print "Parent Dieing off: Forking to Daemon\n";
exit;
}
if (!isset($pid)) {
die ("Could not fork");
}
We are now a Daemon
$got_signel = 0;
do { sleep(1); } while(!got_signel);
as a note daemons shouldn't talk
print "We Get Signel\nMain Screen Turn on\nHow are you gentlemen\n All your base are belong to us\n";
exit;
function sig_handler($signo) {
global $got_signel;
if ($signo == SIGUSR1) {
$got_signel = 1;
}
}