Skip to content

Instantly share code, notes, and snippets.

@jsjohnst
Created August 8, 2012 19:18
Show Gist options
  • Select an option

  • Save jsjohnst/3297804 to your computer and use it in GitHub Desktop.

Select an option

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

aldeek commented Mar 31, 2020

Copy link
Copy Markdown

How after hour?

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