# File lib/win32/process.rb, line 44
   def waitpid(pid)
      exit_code = [0].pack('L')
      handle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
      
      if handle == INVALID_HANDLE_VALUE
         raise ProcessError, get_last_error
      end
      
      # TODO: update the $? global variable (if/when possible)
      status = WaitForSingleObject(handle, INFINITE)
      
      unless GetExitCodeProcess(handle, exit_code)
         raise ProcessError, get_last_error
      end
      
      CloseHandle(handle)
      @child_pids.delete(pid)
      
      # TODO: update the $? global variable (if/when possible)
      exit_code = exit_code.unpack('L').first
      
      pid
   end