aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-30 08:03:26 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-30 08:03:26 +0000
commitf7d07b1723c15ee818f0c1f5cce96c55274024a6 (patch)
treeb7f847c25ce3705d315ce4f0ac1b7976fae58cc6 /procps
parent42ee26d00cc9c9a6cf1f652a5351b30ac221fa34 (diff)
downloadbusybox-w32-f7d07b1723c15ee818f0c1f5cce96c55274024a6.tar.gz
busybox-w32-f7d07b1723c15ee818f0c1f5cce96c55274024a6.tar.bz2
busybox-w32-f7d07b1723c15ee818f0c1f5cce96c55274024a6.zip
killall, pidof: use argv0 for process matching too
top: show cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name) function old new delta find_pid_by_name 98 156 +58 procps_scan 692 732 +40 top_main 2724 2762 +38 find_pair 164 180 +16 collect_int 114 123 +9 cmp_main 547 555 +8 collect_fork 112 119 +7 collect_ctx 112 119 +7 read_package_field 253 257 +4 passwd_main 1983 1985 +2 process_stdin 435 433 -2 xstrtoul_range_sfx 229 226 -3 get_next_block 1852 1849 -3 arith 2042 2033 -9 sv_main 1236 1226 -10 singlemount 4690 4672 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 10/6 up/down: 189/-45) Total: 144 bytes text data bss dec hex filename 734789 3028 14400 752217 b7a59 busybox_old 734933 3028 14400 752361 b7ae9 busybox_unstripped
Diffstat (limited to 'procps')
-rw-r--r--procps/top.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/procps/top.c b/procps/top.c
index c6efe2d77..136f1404a 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -40,7 +40,8 @@ typedef struct top_status_t {
40 unsigned pid, ppid; 40 unsigned pid, ppid;
41 unsigned uid; 41 unsigned uid;
42 char state[4]; 42 char state[4];
43 char comm[COMM_LEN]; 43/* TODO: read /proc/$PID/cmdline only for processes which are displayed */
44 char cmd[64];
44} top_status_t; 45} top_status_t;
45 46
46typedef struct jiffy_counts_t{ 47typedef struct jiffy_counts_t{
@@ -444,7 +445,7 @@ static void display_status(int count, int scr_width)
444#endif 445#endif
445 ); 446 );
446 if (col > 0) 447 if (col > 0)
447 printf("%.*s", col, s->comm); 448 printf("%.*s", col, s->cmd);
448 /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, 449 /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu,
449 jif.busy - prev_jif.busy, jif.total - prev_jif.total); */ 450 jif.busy - prev_jif.busy, jif.total - prev_jif.total); */
450 s++; 451 s++;
@@ -559,6 +560,7 @@ int top_main(int argc, char **argv)
559 | PSSCAN_UTIME 560 | PSSCAN_UTIME
560 | PSSCAN_STATE 561 | PSSCAN_STATE
561 | PSSCAN_COMM 562 | PSSCAN_COMM
563 | PSSCAN_CMD
562 | PSSCAN_SID 564 | PSSCAN_SID
563 | PSSCAN_UIDGID 565 | PSSCAN_UIDGID
564 ))) { 566 ))) {
@@ -572,7 +574,10 @@ int top_main(int argc, char **argv)
572#endif 574#endif
573 top[n].uid = p->uid; 575 top[n].uid = p->uid;
574 strcpy(top[n].state, p->state); 576 strcpy(top[n].state, p->state);
575 strcpy(top[n].comm, p->comm); 577 if (p->cmd)
578 safe_strncpy(top[n].cmd, p->cmd, sizeof(top[n].cmd));
579 else /* mimic ps */
580 sprintf(top[n].cmd, "[%s]", p->comm);
576 } 581 }
577 if (ntop == 0) { 582 if (ntop == 0) {
578 bb_error_msg_and_die("no process info in /proc"); 583 bb_error_msg_and_die("no process info in /proc");
@@ -585,6 +590,7 @@ int top_main(int argc, char **argv)
585 continue; 590 continue;
586 } 591 }
587 do_stats(); 592 do_stats();
593/* TODO: we don't need to sort all 10000 processes, we need to find top 24! */
588 qsort(top, ntop, sizeof(top_status_t), (void*)mult_lvl_cmp); 594 qsort(top, ntop, sizeof(top_status_t), (void*)mult_lvl_cmp);
589#else 595#else
590 qsort(top, ntop, sizeof(top_status_t), (void*)sort_function); 596 qsort(top, ntop, sizeof(top_status_t), (void*)sort_function);