def wait_for_fork(pid, raise_error=True, expected_exitcode=0):
 rc = 0
 try:
  (pid, rc) = os.waitpid(pid, 0)
  rc = os.WEXITSTATUS(rc)
  if (rc != expected_exitcode):
   raise RuntimeError(('The exit code %d is not %d' % (rc, expected_exitcode)))
 except Exception:
  if raise_error:
   raise
 return rc

def wait_for_fork ( pid , raise_error = True , expected_exitcode = 0 ) : rc = 0 try : ( pid , rc ) = os . waitpid ( pid , 0 ) rc = os . WEXITSTATUS ( rc ) if ( rc != expected_exitcode ) : raise RuntimeError ( ( 'The exit code %d is not %d' % ( rc , expected_exitcode ) ) ) except Exception : if raise_error : raise return rc
wait for a process to complete this function will wait for the given pid to complete .