def get_root_helper_child_pid(pid, expected_cmd, run_as_root=False):
 pid = str(pid)
 if run_as_root:
  while True:
   try:
    pid = find_child_pids(pid)[0]
   except IndexError:
    return
   if pid_invoked_with_cmdline(pid, expected_cmd):
    break
 return pid

def get_root_helper_child_pid ( pid , expected_cmd , run_as_root = False ) : pid = str ( pid ) if run_as_root : while True : try : pid = find_child_pids ( pid ) [ 0 ] except IndexError : return if pid_invoked_with_cmdline ( pid , expected_cmd ) : break return pid
get the first non root_helper child pid in the process hierarchy .