I'm running php scripts from CLI, and i'd like to execute a function when script stopped with ctrl + c. I tried this:
<?php
declare(ticks = 1);
function sigint() {
echo 'This is the end';
exit;
}
pcntl_signal(SIGTERM, 'sigint');
$i = 1;
do {
echo $i++ . ' ';
sleep(1);
} while (TRUE);
but it doesn't works. How can i do this?