os.wait() losing child?

greg greg at cosc.canterbury.ac.nz
Tue Jul 10 20:59:31 EDT 2007


Jason Zheng wrote:
> while (True):
>   pid = os.wait()
>   ...
>   if (someCondition):
>     break
 >   ...

Are you sure that someCondition() always becomes true
when the list of pids is empty? If not, you may end
up making more wait() calls than there are children.

It might be safer to do

   while pids:
     ...

--
Greg



More information about the Python-list mailing list