well... playing with fork() in a phpcli script, i got some troubles with childs... anybody knows how to dont get zombies/defuncts with SIGCHLD and SIGCLD ignoring ? dont worked for me =/
the script is large, so the main pieces of it.. i dont want to know how many childs are running, or if they terminated or not... i want only to make childs :D ignoring SIGCHLD in perl works finely... is there anything about the "phped-layer" to syscalls access ? duh.. =] <? declare (ticks = 1); //original sighangler, not used anymore... i know :) function sig_handler($signo) { out("[+] SIG: $signo\n"); $pid = pcntl_waitpid(-1, &$status, WNOHANG); if ($signo == SIGCHLD) out("[+] SIGCHLD PID:$pid\n"); if ($signo == SIGCLD) out("[+] SIGCLD PID: $pid\n"); //posix_kill($pid, SIGTERM); } pcntl_signal(SIGCLD, SIG_IGN); pcntl_signal(SIGCHLD, SIG_IGN); $n = 0; while (1) { $n++; $pid = pcntl_fork(); if ($pid == -1) { out("[+] error in fork.\n"); exit(-1); } if ($pid == 0) { // child... $pid = posix_getpid(); out("[+] im the number $n !!!\n"); // do some job... exit(0); } else { // im parent... if (($n % 100) == 0) { out("[+] giving some time for childs...\n"); sleep(10); $n = 0; out("[+] making more childs ;D\n"); } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php