Skip to content

Instantly share code, notes, and snippets.

@tarunlalwani
Created April 20, 2018 11:44
Show Gist options
  • Save tarunlalwani/6b4f2b81f20c781234899e62f22b0436 to your computer and use it in GitHub Desktop.
Save tarunlalwani/6b4f2b81f20c781234899e62f22b0436 to your computer and use it in GitHub Desktop.
<?php
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
declare(ticks=1);
//pcntl_async_signals(true);
$shutdownHandler = function () {
echo 'Exiting';
// exit();
};
pcntl_signal(SIGINT, $shutdownHandler);
pcntl_wait($status); //Protect against Zombie children
} else {
// we are the child
echo "hanging now";
while (true) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://blackhole.webpagetest.org');
curl_exec($ch);
curl_close($ch);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment