Skip to content

Instantly share code, notes, and snippets.

@smathy
Created June 23, 2010 17:06
Show Gist options
  • Save smathy/450209 to your computer and use it in GitHub Desktop.
Save smathy/450209 to your computer and use it in GitHub Desktop.
## Doesn't work
<?php
declare(ticks = 1);
function sig_handler($s) {
die("Caught ALARM\n");
}
pcntl_signal(SIGALRM, "sig_handler", true);
pcntl_alarm(2);
mysql_connect('localhostxx');
die("Connected fine.");
?>
## Works
<?php
declare(ticks = 1);
function sig_handler($s) {
die("Caught ALARM\n");
}
pcntl_signal(SIGALRM, "sig_handler", true);
pcntl_alarm(2);
for(;;) {}
?>
## This one works (ie. gets to the connection)
<?php
declare(ticks = 1);
function sig_handler($s) {
die("Caught ALARM\n");
}
pcntl_signal(SIGALRM, "sig_handler", true);
pcntl_alarm(2);
mysql_connect('localhost');
die("Connected fine.");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment