I have a script toto1.php which call an other script toto2.php in background.
toto1.php
$command = 'nohup php toto2.php > /dev/null 2> /dev/null &';
exec($command);
while (true) {
echo "sleep...
";
sleep(1);
}
toto2.php
<?php
function signalHandler($signal)
{
echo "SIGNAL: $signal
";
exit;
}
pcntl_signal(SIGINT, 'signalHandler');
for ($i = 0;;$i++) {
pcntl_signal_dispatch();
echo "HELLO $i
";
sleep(1);
}
When I launch toto1.php
on a terminal and kill it with ctrl+c
, a SIGINT
signal is sent to toto2.php
. How can I prevent toto1.php
to send signal to toto2.php
when it is killed?
Regards