Skip to content

Instantly share code, notes, and snippets.

@jsjohnst
Created August 8, 2012 19:18
Show Gist options
  • Save jsjohnst/3297804 to your computer and use it in GitHub Desktop.
Save jsjohnst/3297804 to your computer and use it in GitHub Desktop.
<?php
declare(ticks = 1);
class TimeoutException extends Exception {};
function signal_handler($signal) {
throw new TimeoutException();
}
pcntl_signal(SIGALRM, "signal_handler", true);
pcntl_alarm(1);
try {
// simulate long executing block
while(1) sleep(30);
} catch(TimeoutException $e) {
echo "Timeout exceeded";
}
echo "done";
@aldeek
Copy link

aldeek commented Mar 31, 2020

How after hour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment