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

ppid should optionally be cached #321

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

ppid should optionally be cached #321

giampaolo opened this issue May 23, 2014 · 9 comments

Comments

@giampaolo
Copy link
Owner

From [email protected] on August 30, 2012 03:41:00

I use psutil in a watch-dog application.  This watch-dog checks for a change in 
ppid to 1.  

Since psutil caches the ppid value, the said watch-dog can't detect when a 
process isn't killed correctly and stuck with parent process id 1.

It would be nice to have access to a non-cached version of ppid.

Original issue: http://code.google.com/p/psutil/issues/detail?id=321

@giampaolo
Copy link
Owner Author

From g.rodola on August 29, 2012 23:15:57

The reason why ppid is cached is because the parent is not supposed to be 
subject to change.
So I ask: how can you have a process whose parent is changing?
BTW, you can already skip the cached version and directly use:
p._platform_impl.get_process_ppid()

@giampaolo
Copy link
Owner Author

From [email protected] on August 30, 2012 02:57:12

The parent can change: when you issue a kill on a process but some child 
process won't exit.  E.g. a bash script with some a chain of piped processes 
and 1+ do not respond do not exit on a broken pipe.  In this case, the process 
gets attached to process 1 (init).

It happens, not doubt about it.
--

Accessing private methods isn't very clean.

@giampaolo
Copy link
Owner Author

From g.rodola on August 30, 2012 03:09:41

What platform(s) are we talking about?
Can you produce a link where this is discussed? 
I've never heard of such a thing and couldn't find any reference about it.

That aside, checking for stuck processes this way sounds unreliable to me.
You might want to try Process.status or use Process.wait() right after you 
killed/terminated the process of interest.

@giampaolo
Copy link
Owner Author

From [email protected] on August 30, 2012 03:17:52

Linux.
See 
http://stackoverflow.com/questions/356722/killing-a-defunct-process-on-unix-system
 for more info.
"Wait" on a process that doesn't respond to kill is of no help.

@giampaolo
Copy link
Owner Author

From g.rodola on August 30, 2012 18:45:42

I'll be in US for a while, not sure when I'll be able to get back to this.

@giampaolo
Copy link
Owner Author

From g.rodola on April 10, 2013 12:21:00

Fixed in revision 465f9dfca8c8 .
The ppid is not only cached on Windows.

Status: FixedInHG
Labels: Milestone-0.6.2 OpSys-UNIX

@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 02:17:39

Labels: -Milestone-0.6.2 Milestone-0.7.0

@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 15:45:26

Labels: -Type-Enhancement Type-Defect

@giampaolo
Copy link
Owner Author

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

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