  first  i adopted your suggestion  honestly  i was hesitating between what you suggested and the current version when i implemented this days ago  if  process isvalid  it could be a direct child of iter  second but has been killed resulting from it is parent process being killed correct it  could  have been if base  process  open  fails  on the other hand  if base  process  open  succeeds but finds a proc with a different parent  due to pid reuse we know that we should ignore this process  however  it is child processes may not be killed yet  so we need to add it is pid to the flat map and continue hunting for the descendant processes  ah  i see  that is a good point  but if the pid was reused  we do not want to kill the new proc s kids  to be totally paranoid  openprocessifchildof would need to report to callers whether the pid was definitively reused or not  i think what you have now is good enough for test code  maybe drop a comment explaining the possibilities since it is a bit subtle  either version works fine for this specific case as killing the direct child process automatically kills all the descendant processes  gpu  utility  etc  per my local tests yes  chrome puts it is sub procs in a job object so that they all should die with the parent  at least  i think that is how it works  you can probably test this trivially by killing a browser proc with plenty of subprocs  i think they evaporate straight away 