in reply to need help with Hanging Child Processes

Are the hung children printing anything before they hang? If not, are they blocked trying to output (i.e. check with 'ps'). Normally when a child is forked, you'll want to redirect its output somewhere else (e.g. a file or a pipe to the parent process) to avoid having the system block them when they try to output.

One quick and dirty way to check if it's blocking on output is to temporarily comment out the print statements in the children. If things start working, then this is probably the problem.

  • Comment on Re: need help with Hanging Child Processes

Replies are listed 'Best First'.
Re^2: need help with Hanging Child Processes
by jyoshv (Novice) on Jan 11, 2005 at 20:37 UTC
    Thanks for your reply. Actually, They are done printing all they have to. "Done! pid = 0" is the last statement before exit(0) for the child. I'm not sure.. what is stoping from exiting Parent forked child # ===> 0, pid = 6382 Parent forked child # ===> 1, pid = 6383 Parent forked child # ===> 2, pid = 6384 started all children 2 Argument "CHLD" isn't numeric in subroutine entry at /usr/lib/perl5/5.6.1/i386-linux/POSIX.pm line 38. Child 0 in sched This is Msg1 Done! pid = 0 Argument "CHLD" isn't numeric in subroutine entry at /usr/lib/perl5/5.6.1/i386-linux/POSIX.pm line 38. Argument "CHLD" isn't numeric in subroutine entry at /usr/lib/perl5/5.6.1/i386-linux/POSIX.pm line 38. Child 0 in sched This is Msg3 Done! pid = 0 Child 0 in sched This is Msg2 Done! pid = 0 Argument "CHLD" isn't numeric in subroutine entry at /usr/lib/perl5/5.6.1/i386-linux/POSIX.pm line 38. Process 6384 exited When I do ps -ef, I can see the parent and 2 of its children hanging. Not sure what to make of that. /opt/jyo/ > ps -ef | grep perl root 6381 4559 98 15:15 pts/0 00:11:56 perl jfork.pl root 6382 6381 0 15:15 pts/0 00:00:00 perl <defunct> root 6383 6381 0 15:15 pts/0 00:00:00 perl <defunct>