$port = $req_list[$i]['port'][$j]; } if ($pid = pcntl_fork()) { continue; } else { if (ob_get_level()) { ob_end_clean(); } register_shutdown_function('shutdown'); // Discard the output buffer and close if (posix_setsid() < 0) { die("child : error"); } // <- This is an error // Do your stuff here my_ping($ip, $port); break; } } function ParseConfigFile(&$req_list) { $xml = simplexml_load_file(YYBTB_XML); $i = 0; $count = 0; // $req_list = array(); foreach ($xml->children() as $child) { foreach ($child->attributes() as $key => $value) { if (strcmp((string) $key, 'mobileip') == 0) { $req_list[$i]['mobileip'] = (string) $value; } else { if (strcmp((string) $key, 'portlist') == 0) {
<?php #version 1.0 define('YYBTB_XML', dirname(__FILE__) . "/yybtb.xml"); $req_list = array(); $count = ParseConfigFile($req_list); # $i = 0; $workers = []; # $worker_num = $count;//创建的进程数 function shutdown() { posix_kill(posix_getpid(), SIGHUP); } echo my_ping('www.baidu.com', 80, 1); $ip = 0; $port = 0; $index = 0; for ($i = 0; $i < sizeof($req_list); $i++) { $ip = $req_list[$i]['mobileip']; for ($j = 0; $j < sizeof($req_list[$i]['port']); $j++) { $port = $req_list[$i]['port'][$j]; } // echo my_ping($ip, $port, 1); } function ParseConfigFile(&$req_list) { $xml = simplexml_load_file(YYBTB_XML); $i = 0; $count = 0; // $req_list = array(); foreach ($xml->children() as $child) {