Created
December 10, 2019 09:18
-
-
Save tahaconfiant/2175a5725d52848c88dd3640268c4f4e to your computer and use it in GitHub Desktop.
get_child_pid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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