1 diff -up procps-3.2.8/top.c.threads procps-3.2.8/top.c
2 --- procps-3.2.8/top.c.threads 2009-10-01 07:14:43.000000000 -0400
3 +++ procps-3.2.8/top.c 2009-10-05 14:05:00.000000000 -0400
4 @@ -1138,6 +1138,7 @@ static proc_t **procs_refresh (proc_t **
5 #define ENTsz sizeof(proc_t)
6 static unsigned savmax = 0; // first time, Bypass: (i)
7 proc_t *ptsk = (proc_t *)-1; // first time, Force: (ii)
9 unsigned curmax = 0; // every time (jeeze)
11 static int show_threads_was_enabled = 0; // optimization
12 @@ -1172,6 +1173,10 @@ static proc_t **procs_refresh (proc_t **
13 while (curmax < savmax) {
15 if (unlikely(!(ptsk = readproc(PT, NULL)))) break;
16 + if(!show_threads_was_enabled)
20 show_threads_was_enabled = 1;
21 while (curmax < savmax) {
23 @@ -1189,7 +1194,7 @@ static proc_t **procs_refresh (proc_t **
27 - free(ptsk); // readproc() proc_t not used
28 + if(!saved_ptsk) free(ptsk); // readproc() proc_t not used
32 @@ -1208,7 +1213,8 @@ static proc_t **procs_refresh (proc_t **
33 else { // show each thread in a process separately
36 - if (likely(ptsk = readproc(PT, NULL))) {
37 + if (likely(ptsk = readproc(PT, NULL)) ||
38 + unlikely(saved_ptsk && (ptsk = saved_ptsk)) ) {
39 show_threads_was_enabled = 1;
41 table = alloc_r(table, (curmax + 1) * PTRsz);
42 @@ -1216,6 +1222,7 @@ static proc_t **procs_refresh (proc_t **
44 table[curmax++] = ttsk;
47 free(ptsk); // readproc() proc_t not used