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

Comments

Projects
None yet
1 participant
@giampaolo
Owner

giampaolo commented May 23, 2014

From JeanLou....@gmail.com 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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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()
Owner

giampaolo commented May 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

From JeanLou....@gmail.com 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.
Owner

giampaolo commented May 23, 2014

From JeanLou....@gmail.com 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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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.
Owner

giampaolo commented May 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

From JeanLou....@gmail.com 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.
Owner

giampaolo commented May 23, 2014

From JeanLou....@gmail.com 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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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.
Owner

giampaolo commented May 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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

Owner

giampaolo commented May 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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

Labels: -Milestone-0.6.2 Milestone-0.7.0

Owner

giampaolo commented May 23, 2014

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

Labels: -Milestone-0.6.2 Milestone-0.7.0

@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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

Labels: -Type-Enhancement Type-Defect

Owner

giampaolo commented May 23, 2014

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

Labels: -Type-Enhancement Type-Defect

@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo May 23, 2014

Owner

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

Status: Fixed

Owner

giampaolo commented May 23, 2014

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

Status: Fixed

@giampaolo giampaolo closed this May 23, 2014

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