# File lib/win32/process.rb, line 475
   def wait2
      handles = []
      
      # Windows 2000 or earlier
      unless defined? GetProcessId
         pids = []
      end
      
      @child_pids.each_with_index{ |pid, i|
         handles[i] = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
         
         if handles[i] == INVALID_HANDLE_VALUE
            err = "unable to get HANDLE on process associated with pid #{pid}"
            raise ProcessError, err
         end
         
         unless defined? GetProcessId
            pids[i] = pid
         end      
      }
    
      wait = WaitForMultipleObjects(
         handles.size,
         handles.pack('L*'),
         0,
         INFINITE
      )
      
      if wait >= WAIT_OBJECT_0 && wait <= WAIT_OBJECT_0 + @child_pids.size - 1
         index = wait - WAIT_OBJECT_0         
         handle = handles[index]
         
         if defined? GetProcessId
            pid = GetProcessId(handle)
         else
            pid = pids[index]
         end
         
         exit_code = [0].pack('l')
         unless GetExitCodeProcess(handle, exit_code)
            raise get_last_error
         end
         
         @child_pids.delete(pid)
         
         handles.each{ |handle| CloseHandle(handle) }
         return [pid, exit_code.unpack('l').first]
      end
      
      nil
   end