in reply to Forking Issues

OK, you don't see it forking, but otherwise is it working? Or is it just hanging/crashing..... We need more information.

Having said that, the way this is written it appears to me that you only ever fork one child process at a time, always waiting for that to complete before doing the next. I fail to see how this will get the improvement you are hoping for.

Maybe you should think about moving the waitpid() call to outside the inside while loop and use waitpid(-1,&WNOHANG) to wait for all child processes as documented in the Camel book.

But thinking about it you probably want to limit the number of child process to some fixed number (eg 10 or 20), so the solution becomes a bit more complicated than that.....

I hope I'm not way off the track here as I haven't used fork() much myself either.

Cheers!

Replies are listed 'Best First'.
Re: Re: Forking Issues
by mildside (Friar) on Aug 07, 2003 at 05:31 UTC
    PS. I suppose you realise that the array @a which you declare twice and assign to once is never used anywhere? I'm guessing this is left over from some debugging or such?

    Cheers!

      Yes, the code works otherwise, and @a was an attempt at something that also didnt work, but I'm more concerned about forking the process of pinging the node. I havent thought about moving the waitpid to outside the loop either. I'll give that a shot.