Skip to content

Instantly share code, notes, and snippets.

@andreyst
Created February 8, 2014 23:13
Show Gist options
  • Save andreyst/8891788 to your computer and use it in GitHub Desktop.
Save andreyst/8891788 to your computer and use it in GitHub Desktop.
<?php
declare(ticks = 1); // needed
function sig_handler($signo) {
echo "Caught $signo...\n";
}
pcntl_signal(SIGUSR1, "sig_handler");
echo 'Hi!' . PHP_EOL;
for ($i = 0; $i < 30; $i++) {
sleep(1); // because signals wake us up, need to sleep again
}
echo 'Bye!' . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment