in reply to Waitpid Woes

You are forking two children from one parent and then seeing the exit code from the first one that happens to die. To see this, try adding an 'else {exit 2}' to the outer fork and try again.

Replies are listed 'Best First'.
Re: Re: Waitpid Woes
by suaveant (Parson) on Dec 17, 2003 at 19:26 UTC
    Well... but the waitpid is in the second fork... shouldn't it only see its one child?

    I had assumed that the waitpid would only catch your direct children.

                    - Ant
                    - Some of my best work - (1 2 3)

      No, the same parent is forking both children. When you say 'if (fork)', the code in the first part of the if is the parent code, the part in the 'else' is the child.
        Duh.

        Doesn't solve my real problem, but solves my test problem, thanks.

                        - Ant
                        - Some of my best work - (1 2 3)