
Danni
Deleted
Mar 27, 2001, 12:54 PM
Post #4 of 4
(2311 views)
|
Re: too many zombies with fork
[In reply to]
|
Can't Post
|
|
Theres a few methods you can use to prevent zombie processes. Basic Method This method uses a blocking wait call to wait on the child processes. Kind of defeats the point, however. if ($pid = fork()) { # The Parent waitpid ($pid,0); } else { # The Child } SIGCHLD Method This method allows multiple processes at one time, much faster but ive found it to cause out of memory errors. Insert before the fork() call. use POSIX ":sys_wait_h"; $SIG{CHLD} = /&waitchild; sub waitchild { while(waitpid(-1,&WNOHANG) > 0) {} $SIG{CHLD} = /&waitchild; } Hope this helps.
|