Guillaume Métayer
2004-09-28 15:55:22 UTC
Hello,
That's a long story but there's a PHP script I need to call in the
background, and the PHP script *never returns*, meaning it's running all the
time (I stop it with Ctrl-C when running it from the console) so I decided
to make a small daemon in C (GCC) on Linux. The daemon simply calls
system("php myscript.php"). The problem is that I can't seem to find a way
to have the PHP process killed when I shutdown my daemon. I tried using
popen or different techniques but basically, when I kill my daemon process,
it doesnt kill the PHP process. My understanding of Unix processes might be
limited but I thought that anything created under a process would die
(unless created as daemon) when parent dies. I know that system uses sh so
sh is the parent, but wouldnt the deamon be sh's parent? Anyway, any help
would be appreciated, thanks,
------
Guillaume
That's a long story but there's a PHP script I need to call in the
background, and the PHP script *never returns*, meaning it's running all the
time (I stop it with Ctrl-C when running it from the console) so I decided
to make a small daemon in C (GCC) on Linux. The daemon simply calls
system("php myscript.php"). The problem is that I can't seem to find a way
to have the PHP process killed when I shutdown my daemon. I tried using
popen or different techniques but basically, when I kill my daemon process,
it doesnt kill the PHP process. My understanding of Unix processes might be
limited but I thought that anything created under a process would die
(unless created as daemon) when parent dies. I know that system uses sh so
sh is the parent, but wouldnt the deamon be sh's parent? Anyway, any help
would be appreciated, thanks,
------
Guillaume