os.wait() losing child?

greg greg at cosc.canterbury.ac.nz
Wed Jul 11 02:59:31 CEST 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