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

per-process status #143

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

per-process status #143

giampaolo opened this issue May 23, 2014 · 11 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on December 27, 2010 15:34:37

This should be similar to STAT column of "ps aux" output and should return an 
integer or a (code, status_str) namedtuple reflecting the current process 
status (running, sleeping, etc...). On Linux this is available via /proc, as 
always, and the code->name mapping can be taken from fs/proc/array.c in the 
Linux kernel source code. 
http://www.takatan.net/lxr/source/fs/proc/array.c#L129 On FreeBSD we can use 
kinfo_proc, as always, but I'm still not sure where to take the name mappings. 
http://fxr.watson.org/fxr/source/sys/user.h#L110 No Idea about OSX and Windows. 
I'm cc-ing wj32.64 in case he knows something about Windows.

Either we choose to return an integer or a nametuple, it probably makes sense 
to expose constants such as psutil.PROC_STATUS_RUNNING, 
psutil.PROC_STATUS_STOPPED, etc. as well.

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

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on December 27, 2010 09:46:02

First draft for Linux and BSD committed as r871 and r872 .

It seems there's no concept of "process status" on Windows. 
We got threads instead, and a thread can be either in a "suspended" or 
"resumed"/"running" state.
I think we can say that a process can be either in a "running" or "suspended" 
state depending on the status of its threads.

Perhaps we might assume that a process is in a "suspended" state if one of its 
threads is supsended, else we can assume it's "running".
There's no API to easily determine such a thing but here are some suggestions: 
http://stackoverflow.com/questions/1006691/how-to-check-if-a-win32-thread-is-running-or-in-suspended-state
 Still not sure whether this is worth the effort, though.

@giampaolo
Copy link
Owner Author

From wj32...@gmail.com on December 27, 2010 12:10:48

You can do this easily by calling NtQuerySystemInformation. If you don't mind, 
I would like to do a rewrite of a lot of the functions to use the undocumented 
functions, as they are far easier to work with than the public ones.

@giampaolo
Copy link
Owner Author

From g.rodola on December 27, 2010 12:30:15

It's ok as long as we do not drop mingw32 support and tests keep passing also 
on 64 bit platforms.
If you're going to rewrite a lot of stuff it'b better if we split the work in 
separate tickets.

As for this specific feature feel free to provide a patch or just commit 
against the trunk (you have write access). As you want.

Is the assumption I made above correct btw? Does processes status on Windows 
work as I guessed?

@giampaolo
Copy link
Owner Author

From wj32...@gmail.com on December 30, 2010 20:18:46

Yes, that's correct. I don't have MinGW so I can't test the support for it. So 
maybe I won't do the rewrite...

@giampaolo
Copy link
Owner Author

From g.rodola on February 15, 2011 03:38:30

Some Windows instructions: 
http://vtopan.wordpress.com/2009/04/15/how-to-find-out-if-a-threadprocess-is-suspended-get-thread-state/

@giampaolo
Copy link
Owner Author

From g.rodola on February 17, 2011 02:33:21

Implemented on OSX in r917 .

Labels: Progress-3in4

@giampaolo
Copy link
Owner Author

From g.rodola on February 21, 2011 19:48:11

Implemented on Windows in r930 .
Thanks to wj32.64 for the help.

Status: FixedInSVN
Labels: -Progress-3in4 Progress-4in4

@giampaolo
Copy link
Owner Author

From g.rodola on February 28, 2011 13:56:01

Labels: Milestone-0.2.1

@giampaolo
Copy link
Owner Author

From g.rodola on March 20, 2011 14:55:37

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on June 09, 2011 15:33:51

Labels: -OpSys-All

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 03:57:44

Updated csets after the SVN -> Mercurial migration: r871 == revision 
0ce06bfb58fe r917 == revision 0a9131af50cc r930 == revision 2c1fe1a56d95

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