|more useful options|
fork() and defunct childrenby xaprb (Scribe)
|on Feb 11, 2008 at 19:54 UTC||Need Help??|
xaprb has asked for the
wisdom of the Perl Monks concerning the following question:
I've written a program to dump MySQL data in parallel. Unfortunately it is behaving oddly. While two children are forked off running mysqldump shell commands, the parent just... hangs. It runs for a while, running waitpid() and forking off more children, but then sometimes it stops and does nothing anymore.
Without posting all the code, which is quite long, here's what I was able to isolate it to:
It hangs just after the ping and before the sleep(). I used DBI tracing to verify that it does call $dbh->ping. But it never gets past that.
So I commented this out. This is non-essential code: it's only there to handle the MySQL server going away and returning, in case there's a crash while you dump the data.
That moved the point of no return just a few lines down, to here:
Again, the hang is in the while() condition: it never reaches a 'print' placed just inside the loop. Meanwhile, top shows that the forked children go on to complete their work and exit, at which point they are defunct but never get reaped.
This is not the only forking program I've written. I'm not an expert at it, but I've never had anything like this happen before.
So my question is, do you have any general advice for me as I try to figure out the problem?