def fork_waitfor_timed(tmp, pid, timeout):
 timer_expired = True
 poll_time = 2
 time_passed = 0
 while (time_passed < timeout):
  time.sleep(poll_time)
  (child_pid, status) = os.waitpid(pid, os.WNOHANG)
  if ((child_pid, status) == (0, 0)):
   time_passed = (time_passed + poll_time)
  else:
   timer_expired = False
   break
 if timer_expired:
  logging.info('Timer expired (%d sec.), nuking pid %d', timeout, pid)
  utils.nuke_pid(pid)
  (child_pid, status) = os.waitpid(pid, 0)
  raise error.TestError(('Test timeout expired, rc=%d' % status))
 else:
  _check_for_subprocess_exception(tmp, pid)
 if status:
  raise error.TestError(('Test subprocess failed rc=%d' % status))

def fork_waitfor_timed ( tmp , pid , timeout ) : timer_expired = True poll_time = 2 time_passed = 0 while ( time_passed < timeout ) : time . sleep ( poll_time ) ( child_pid , status ) = os . waitpid ( pid , os . WNOHANG ) if ( ( child_pid , status ) == ( 0 , 0 ) ) : time_passed = ( time_passed + poll_time ) else : timer_expired = False break if timer_expired : logging . info ( 'Timer expired (%d sec.), nuking pid %d' , timeout , pid ) utils . nuke_pid ( pid ) ( child_pid , status ) = os . waitpid ( pid , 0 ) raise error . TestError ( ( 'Test timeout expired, rc=%d' % status ) ) else : _check_for_subprocess_exception ( tmp , pid ) if status : raise error . TestError ( ( 'Test subprocess failed rc=%d' % status ) )
waits for pid until it terminates or timeout expires .