Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows' PID re-use not considered in Process.ppid, Process.parent, at least in process_info.c:get_ppid() #356

Closed
giampaolo opened this issue May 23, 2014 · 2 comments

Comments

@giampaolo
Copy link
Owner

From clackw...@googlemail.com on March 12, 2013 05:07:30

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: http://code.google.com/p/psutil/issues/detail?id=356

@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 03:59:06

Fixed in revision 25aff1ab8dbc .
Thanks.

Status: FixedInHG
Labels: Milestone-0.7.0

@giampaolo
Copy link
Owner Author

From g.rodola on April 12, 2013 11:21:27

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant