diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-12-02 16:11:42 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-12-02 16:11:42 -0200 |
commit | ea50df0bf5faf22f1aa37c70fc2a44b9151a7a92 (patch) | |
tree | b00555b1b573b71205da887a3e4cb46db7b6fd2f | |
parent | 68181ca96bdb981a4b3ef94909d960349e22e927 (diff) | |
download | python-linux-procfs-ea50df0bf5faf22f1aa37c70fc2a44b9151a7a92.tar.gz |
pidstats: Introduce process_flags method
Usage example:
>>> import procfs
>>> ps = procfs.pidstats()
>>> for t in ps.find_by_name("sirq-net-tx/6"):
... print "%s: %s" % (t, ps.process_flags(t))
...
85: ['PF_FORKNOEXEC', 'PF_NOFREEZE', 'PF_SUPERPRIV', 'PF_THREAD_BOUND']
>>> for t in ps.find_by_name("pdflush"):
... print "%s: %s" % (t, ps.process_flags(t))
...
398: ['PF_FLUSHER', 'PF_FORKNOEXEC', 'PF_SWAPWRITE']
399: ['PF_FLUSHER', 'PF_FORKNOEXEC', 'PF_SWAPWRITE']
>>>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py index 33b1a40..bbe2118 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -204,6 +204,18 @@ class pidstats: return int(self.processes[pid]["stat"]["flags"]) & \ self.PF_THREAD_BOUND and True or False + def process_flags(self, pid): + sflags = [] + flags = int(self.processes[pid]["stat"]["flags"]) + for attr in dir(self): + if attr[:3] != "PF_": + continue + value = getattr(self, attr) + if value & flags: + sflags.append(attr) + + return sflags + class interrupts: def __init__(self): self.interrupts = {} |