pcntl_signal isn't triggered by the child process

Hi,

I want to achieve this:

if the daemon gets SIGHUP than run the process again (as child) and kill the parent.

When i’m running it, the first time is working:

[code]> php test.php

kill -HUP pid
ps -ef |grep test.php
result:… newPID test.php
[/code]
The problem is that if now i’m killing the child process,the function is not triggered

> kill -HUP newPID
> ps -ef |grep test.php
> result: ... newPID(the same) test.php

The code:

test.php:
<?php
   declare(ticks = 1);

   $mypid = posix_getpid();

   function sig_handler()
   {

   Global $mypid;
   echo "Received sighup, we need to reload ourselves now \n";
   echo "mypid:$mypid \n";
   system("(php test.php)>/dev/null &");

   posix_kill($mypid,9);

   }

   pcntl_signal(SIGHUP,  "sig_handler");

   sleep(500);

   ?>

This code works on PHP 5.2.9 but not on PHP 5.3.5. Is there any way to make it works also on that version?

Thanks!

Ronny

Sponsor our Newsletter | Privacy Policy | Terms of Service