Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl fork() zombie problems. 1

Status
Not open for further replies.

ddlink

Technical User
Jan 10, 2002
20
SE
Hi all,

this is my first post here so please bare with me :)

I would like to do roughly the following:

Code:
while (<>) {
  if (something) {
     unless (fork) { mail($_); }
  }

sub mail
{
  mailingcode....
  exit();
}

But this gives me zombies and ps -ef shows (defunct) on both parent and child. Now every child could take several minutes to complete and it is possible that the parents would be able to create several childs during a minute.

How would I solve this (detaching the child from the parent) without waiting inside the parentloop?

Any help or directions is appreciated
 
I took this right out of perldoc. You can read it in its
entirty by typing &quot;perldoc -f fork&quot; on your command line.

From perldoc::::::::


If you &quot;fork&quot; without ever waiting on your children, you will
accumulate zombies. On some systems, you can avoid this by
setting &quot;$SIG{CHLD}&quot; to &quot;&quot;IGNORE&quot;&quot;. See also the perlipc manpage
for more examples of forking and reaping moribund children.
 
Thanks, seems to work as it should. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top