http://qs1969.pair.com?node_id=257473


in reply to PID after fork && exit

fork returns the child PID, or 0 for the parent, AFAIK

Smitz

Replies are listed 'Best First'.
Re: PID after fork && exit
by Abigail-II (Bishop) on May 12, 2003 at 20:23 UTC
    That's very confusing what you write.

    If fork fails, undef is returned. If fork succeeds, different values are returned in the parent and the child. In the child, fork returns 0, while in the parent, the process ID of child is returned. This is the only convenient time for the parent to get the process ID of the child. A parent can get the process ID of the child when it's reaping the child with some form of wait call, but then the child has already finished. Otherwise, the parents rests nothing else than walking the process list.

    Abigail