Skip to content

Instantly share code, notes, and snippets.

@tahaconfiant
Created December 10, 2019 09:18
Show Gist options
  • Save tahaconfiant/2175a5725d52848c88dd3640268c4f4e to your computer and use it in GitHub Desktop.
Save tahaconfiant/2175a5725d52848c88dd3640268c4f4e to your computer and use it in GitHub Desktop.
get_child_pid
def get_child_pid(process_name, parent_pid):
child_pid = 0
for pid in check_output(["pgrep", process_name]).split():
print ("found new pid: %i\n" % int(pid))
if parent_pid == int(pid):
continue
elif int(pid) > parent_pid:
child_pid = int(pid)
break
else:
continue
return child_pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment