diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-01-28 17:50:07 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-01-28 17:50:07 -0200 |
commit | f5f34d2c3609c37c690cfbcc4581b7e79a1f6447 (patch) | |
tree | 3bcf1a2b482b137e0e2e95ab85d5f96479609ef8 | |
parent | 92a0821bf269fc3bb90e536f111ff349ff3187ce (diff) | |
download | tuna-f5f34d2c3609c37c690cfbcc4581b7e79a1f6447.tar.gz |
tuna: Handle zombies in tuna.iskthread
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | tuna/tuna.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tuna/tuna.py b/tuna/tuna.py index 0d2c8ce..46c2d46 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -53,8 +53,10 @@ def kthread_help_plain_text(pid, cmdline): return help, title -# Zombies also doesn't have smaps entries, but it should be good enough def iskthread(pid): + # FIXME: we should leave to the callers to handle all the exceptions, + # in this function, so that they know that the thread vanished and + # can act accordingly, removing entries from tree views, etc try: f = file("/proc/%d/smaps" % pid) except IOError: @@ -63,7 +65,19 @@ def iskthread(pid): line = f.readline() f.close() - return not line + if line: + return False + # Zombies also doesn't have smaps entries, so check the + # state: + try: + p = procfs.pidstat(pid) + except: + return True + + if p["state"] == 'Z': + return False + return True + # FIXME: Move to python-linux-procfs def has_threaded_irqs(irqs, ps): |