in reply to Re: Understanding fork + wait
in thread Understanding fork + wait

Very light load, but a few connections may come in simultaneously.

The problems are gone with my "fix". I just wonder if it's the right fix :)


/J

Replies are listed 'Best First'.
Re: Re: Re: Understanding fork + wait
by agentv (Friar) on Oct 29, 2002 at 17:56 UTC
    ...this puzzled me for a while, but the quick answer is, "yes, you are fixing the right problem." It was robartes observation that led me to this conclusion.

    Essentially, you are using three process structures in each service event by your server.

    Primary Server Client Service instance Process created by system()

    I believe that it was the third of those that was returning ECHILD. By resetting handlers on the second level, you made it it possible for the second level process to call wait() appropriately upon the death of its child.

    I just peeked to see if I could find evidence that signal handlers for ignored signals are reset during exec() but my notes (for Solaris anyway) say only that signals with handlers are reset to default during exec(). That makes sense because the signal handlers would be part of the parent's process address space, but would not be available to the child. I guess it doesn't matter what that third-level process does with the SIGCHLD because it (presumably) doesn't have any children.

    But you do want the second-level process to clean up its child proc structure (ie. to harvest its exit code) when the call to system() is complete.

    I don't know if this helps, but I believe that you did the right thing. Bring us back in here if you see any other odd symptoms from your system.

    ...All the world looks like -well- all the world, when your hammer is Perl.
    ---v