Reputation: 339
Scenario: subprocess created a subprocess and so on, how can i get it's pid?
I used subprocess.popen to launch the first subprocess, for example word file, this word file generated a new subprocess, how can i get it's pid?
Upvotes: 0
Views: 1500
Reputation: 6794
Using psutil:
parent = psutil.Process(parent_pid)
children = parent.children()
# all child pids can be accessed using the pid attribute
child_pids = [p.pid for p in children]
Upvotes: 1