waste of resources ?
greg.ewing at compaq.com
Wed Jun 16 23:46:08 CEST 1999
Aahz Maruch wrote:
> I can't speak to Arne's situation, but I'm about to rewrite a chunk of
> code to fork off a specific single child process precisely because I
> *don't* want the parent to block while this code executes, but I still
> want to reap the child later (and perform some final cleanup).
If you have some way of knowing when the child has finished
doing its thing (such as having received results from it),
you can do a blocking wait for that particular pid at that
point, because you know the child has either exited already
or is about to do so very soon.
If you have no idea when the child is expected to exit, your
only portable option is a SIGCHLD handler which loops doing non-blocking
waits until no more children are reaped. The loop is necessary
because if more than one child exits before the handler is
entered, you won't get any extra signals.
More information about the Python-list