diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-01-09 11:12:54 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-01-09 11:12:54 -0200 |
commit | bcba521b43261e46e4c599a826e0f05504a3ef85 (patch) | |
tree | dc8f6f0002ded0c9d16eba4cdfb52be78d4003e7 | |
parent | 79b8bb97ef10f15deb449d1e4d9bbc2636e741a0 (diff) | |
download | tuna-bcba521b43261e46e4c599a826e0f05504a3ef85.tar.gz |
cmdline: Check if thread names resolved to TIDs
Without this when we ran:
[root@doppio tuna]# tuna -t fire -CP
And there were no 'fire' named threads, all threads would be printed,
now:
[root@doppio tuna]# tuna -t fire -CP
[root@doppio tuna]# tuna -t firefox -CP
thread ctxt_switches
pid SCHED_ rtpri affinity voluntary nonvoluntary cmd
1079 OTHER 0 0,1 10970427 8259378 firefox
1133 OTHER 0 0,1 847 38 firefox
1095 OTHER 0 0,1 10436470 2426532 firefox
23722 OTHER 0 0,1 16 9 firefox
19341 OTHER 0 0,1 66253 6496 firefox
1134 OTHER 0 0,1 6 0 firefox
1135 OTHER 0 0,1 21500 7624 firefox
[root@doppio tuna]#
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | tuna-cmd.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py index 11d8481..29fab54 100755 --- a/tuna-cmd.py +++ b/tuna-cmd.py @@ -254,6 +254,7 @@ def main(): cpu_list = None irq_list = None thread_list = None + thread_list_str = None filter = False affect_children = False @@ -273,6 +274,13 @@ def main(): map(thread_mapper, a.split(","))) op_list = list(set(op_list)) thread_list = do_list_op(op, thread_list, op_list) + # Check if a process name was especified and no + # threads was found, which would result in an empty + # thread list, i.e. we would print all the threads + # in the system when we should print nothing. + if not op_list and type(a) == type(''): + thread_list_str = do_list_op(op, thread_list_str, + a.split(",")) if not op: irq_list = None elif o in ("-f", "--filter"): @@ -292,6 +300,10 @@ def main(): elif o in ("-p", "--priority"): tuna.threads_set_priority(thread_list, a, affect_children) elif o in ("-P", "--show_threads"): + # If the user specified process names that weren't + # resolved to pids, don't show all threads. + if thread_list_str and not thread_list: + continue do_ps(thread_list, cpu_list, irq_list, uthreads, kthreads, affect_children) elif o in ("-m", "--move", "-x", "--spread"): |