Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function requestUrl($url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- curl_close($ch);
- echo md5($output)."\n";
- }
- $urls = [
- "http://php.net", // Will work fine
- "https://stackoverflow.com/", // Will fail
- ];
- // First, request an HTTPS url, required for the bug to occur
- requestUrl("https://facebook.com");
- foreach ($urls as $url) {
- $pid = pcntl_fork();
- if ($pid == -1) {
- throw new \Exception('Could not fork');
- } else if ($pid) {
- // Parent process
- pcntl_waitpid($pid, $status);
- print_r([
- "URL" => $url,
- "Successful Exit" => pcntl_wifexited($status) ? "Yes" : "No",
- "Exit Code" => pcntl_wexitstatus($status)
- ]);
- echo "\n";
- } else {
- // Child process
- requestUrl($url);
- exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement