Looking at process_info.c, get_ppid() it seems that it does not consider PID
reuse, because it does not check if the found process has a creation time
smaller than or equal to the current process.
As a workaround: If process.parent returns a Process reference the creation
time of that process should be checked to ensure that the parent process is
older than or as old as the process (a sub-process can have the same creation
timestamp as its parent process, IIRC what a colleague once reported):
def my_get_ppid(process):
pp = process.parent
if pp is not None:
# Check if parent process is younger than
# process:
if pp.create_time > process.create_time:
return None
return pp.pid
def my_get_parent(process):
if my_get_ppid(process) is not None:
return process.parent
return None
Possibly related issue: https://code.google.com/p/psutil/issues/detail?id=314
Original issue reported on code.google.com by clackw...@googlemail.com on 12 Mar 2013 at 4:07
Original issue reported on code.google.com by
clackw...@googlemail.com
on 12 Mar 2013 at 4:07