diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/kill.c | 30 | ||||
-rw-r--r-- | procps/pidof.c | 36 | ||||
-rw-r--r-- | procps/ps.c | 8 | ||||
-rw-r--r-- | procps/top.c | 9 |
4 files changed, 44 insertions, 39 deletions
diff --git a/procps/kill.c b/procps/kill.c index b29f61b58..f22bdbe46 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -103,31 +103,31 @@ do_it_now: | |||
103 | } | 103 | } |
104 | 104 | ||
105 | /* Pid or name required for kill/killall */ | 105 | /* Pid or name required for kill/killall */ |
106 | if (argc<1) | 106 | if (argc < 1) |
107 | bb_show_usage(); | 107 | bb_show_usage(); |
108 | 108 | ||
109 | if (killall) { | 109 | if (killall) { |
110 | /* Looks like they want to do a killall. Do that */ | 110 | /* Looks like they want to do a killall. Do that */ |
111 | pid = getpid(); | 111 | pid = getpid(); |
112 | while (arg) { | 112 | while (arg) { |
113 | long* pidList; | 113 | pid_t* pidList; |
114 | 114 | ||
115 | pidList = find_pid_by_name(arg); | 115 | pidList = find_pid_by_name(arg); |
116 | if (!pidList || *pidList<=0) { | 116 | if (*pidList == 0) { |
117 | errors++; | 117 | errors++; |
118 | if (!quiet) | 118 | if (!quiet) |
119 | bb_error_msg("%s: no process killed", arg); | 119 | bb_error_msg("%s: no process killed", arg); |
120 | } else { | 120 | } else { |
121 | long *pl; | 121 | pid_t *pl; |
122 | 122 | ||
123 | for (pl = pidList; *pl!=0; pl++) { | 123 | for (pl = pidList; *pl; pl++) { |
124 | if (*pl==pid) | 124 | if (*pl == pid) |
125 | continue; | 125 | continue; |
126 | if (kill(*pl, signo)!=0) { | 126 | if (kill(*pl, signo) == 0) |
127 | errors++; | 127 | continue; |
128 | if (!quiet) | 128 | errors++; |
129 | bb_perror_msg("cannot kill pid %ld", *pl); | 129 | if (!quiet) |
130 | } | 130 | bb_perror_msg("cannot kill pid %u", (unsigned)*pl); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | free(pidList); | 133 | free(pidList); |
@@ -138,12 +138,14 @@ do_it_now: | |||
138 | 138 | ||
139 | /* Looks like they want to do a kill. Do that */ | 139 | /* Looks like they want to do a kill. Do that */ |
140 | while (arg) { | 140 | while (arg) { |
141 | if (!isdigit(arg[0]) && arg[0]!='-') | 141 | /* Huh? |
142 | if (!isdigit(arg[0]) && arg[0] != '-') | ||
142 | bb_error_msg_and_die("bad pid '%s'", arg); | 143 | bb_error_msg_and_die("bad pid '%s'", arg); |
144 | */ | ||
143 | pid = xatou(arg); | 145 | pid = xatou(arg); |
144 | /* FIXME: better overflow check? */ | 146 | /* FIXME: better overflow check? */ |
145 | if (kill(pid, signo)!=0) { | 147 | if (kill(pid, signo) != 0) { |
146 | bb_perror_msg("cannot kill pid %ld", (long)pid); | 148 | bb_perror_msg("cannot kill pid %u", (unsigned)pid); |
147 | errors++; | 149 | errors++; |
148 | } | 150 | } |
149 | arg = *++argv; | 151 | arg = *++argv; |
diff --git a/procps/pidof.c b/procps/pidof.c index 62c590fd8..28c5c04e2 100644 --- a/procps/pidof.c +++ b/procps/pidof.c | |||
@@ -18,18 +18,18 @@ | |||
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | #if ENABLE_FEATURE_PIDOF_OMIT | 20 | #if ENABLE_FEATURE_PIDOF_OMIT |
21 | #define _OMIT_COMPL(a) a | 21 | # define _OMIT_COMPL(a) a |
22 | #define _OMIT(a) ,a | 22 | # define _OMIT(a) ,a |
23 | #if ENABLE_FEATURE_PIDOF_SINGLE | 23 | # if ENABLE_FEATURE_PIDOF_SINGLE |
24 | #define OMIT (1<<1) | 24 | # define OMIT (1<<1) |
25 | #else | 25 | # else |
26 | #define OMIT (1<<0) | 26 | # define OMIT (1<<0) |
27 | #endif | 27 | # endif |
28 | #else | 28 | #else |
29 | #define _OMIT_COMPL(a) "" | 29 | # define _OMIT_COMPL(a) "" |
30 | #define _OMIT(a) | 30 | # define _OMIT(a) |
31 | #define OMIT (0) | 31 | # define OMIT (0) |
32 | #define omitted (0) | 32 | # define omitted (0) |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | int pidof_main(int argc, char **argv) | 35 | int pidof_main(int argc, char **argv) |
@@ -65,21 +65,23 @@ int pidof_main(int argc, char **argv) | |||
65 | #endif | 65 | #endif |
66 | /* Looks like everything is set to go. */ | 66 | /* Looks like everything is set to go. */ |
67 | while (optind < argc) { | 67 | while (optind < argc) { |
68 | long *pidList; | 68 | pid_t *pidList; |
69 | long *pl; | 69 | pid_t *pl; |
70 | 70 | ||
71 | /* reverse the pidlist like GNU pidof does. */ | 71 | /* reverse the pidlist like GNU pidof does. */ |
72 | pidList = pidlist_reverse(find_pid_by_name(argv[optind])); | 72 | pidList = pidlist_reverse(find_pid_by_name(argv[optind])); |
73 | for (pl = pidList; *pl > 0; pl++) { | 73 | for (pl = pidList; *pl; pl++) { |
74 | #if ENABLE_FEATURE_PIDOF_OMIT | 74 | #if ENABLE_FEATURE_PIDOF_OMIT |
75 | unsigned omitted = 0; | 75 | unsigned omitted = 0; |
76 | if (opt & OMIT) { | 76 | if (opt & OMIT) { |
77 | llist_t *omits_p = omits; | 77 | llist_t *omits_p = omits; |
78 | while (omits_p) | 78 | while (omits_p) { |
79 | if (xatoul(omits_p->data) == *pl) { | 79 | if (xatoul(omits_p->data) == *pl) { |
80 | omitted = 1; break; | 80 | omitted = 1; |
81 | break; | ||
81 | } else | 82 | } else |
82 | omits_p = omits_p->link; | 83 | omits_p = omits_p->link; |
84 | } | ||
83 | } | 85 | } |
84 | #endif | 86 | #endif |
85 | if (!omitted) { | 87 | if (!omitted) { |
@@ -88,7 +90,7 @@ int pidof_main(int argc, char **argv) | |||
88 | } else { | 90 | } else { |
89 | n = 1; | 91 | n = 1; |
90 | } | 92 | } |
91 | printf("%ld", *pl); | 93 | printf("%u", (unsigned)*pl); |
92 | } | 94 | } |
93 | fail = (!ENABLE_FEATURE_PIDOF_OMIT && omitted); | 95 | fail = (!ENABLE_FEATURE_PIDOF_OMIT && omitted); |
94 | 96 | ||
diff --git a/procps/ps.c b/procps/ps.c index 97e239b07..df4dcc4fc 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -58,7 +58,7 @@ int ps_main(int argc, char **argv) | |||
58 | len = sizeof(sbuf); | 58 | len = sizeof(sbuf); |
59 | 59 | ||
60 | if (is_selinux_enabled()) { | 60 | if (is_selinux_enabled()) { |
61 | if (getpidcon(p->pid,&sid) < 0) | 61 | if (getpidcon(p->pid, &sid) < 0) |
62 | sid = NULL; | 62 | sid = NULL; |
63 | } | 63 | } |
64 | 64 | ||
@@ -71,14 +71,14 @@ int ps_main(int argc, char **argv) | |||
71 | } else { | 71 | } else { |
72 | safe_strncpy(sbuf, "unknown", 7); | 72 | safe_strncpy(sbuf, "unknown", 7); |
73 | } | 73 | } |
74 | len = printf("%5d %-32s %s ", p->pid, sbuf, p->state); | 74 | len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state); |
75 | } | 75 | } |
76 | else | 76 | else |
77 | #endif | 77 | #endif |
78 | if (p->rss == 0) | 78 | if (p->rss == 0) |
79 | len = printf("%5d %-8s %s ", p->pid, p->user, p->state); | 79 | len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state); |
80 | else | 80 | else |
81 | len = printf("%5d %-8s %6ld %s ", p->pid, p->user, p->rss, p->state); | 81 | len = printf("%5u %-8s %6ld %s ", (unsigned)p->pid, p->user, p->rss, p->state); |
82 | 82 | ||
83 | i = terminal_width-len; | 83 | i = terminal_width-len; |
84 | 84 | ||
diff --git a/procps/top.c b/procps/top.c index d58fdda97..3ff61dfa7 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -78,7 +78,7 @@ static int mult_lvl_cmp(void* a, void* b) { | |||
78 | the next. Mostly used for sorting. */ | 78 | the next. Mostly used for sorting. */ |
79 | struct save_hist { | 79 | struct save_hist { |
80 | int ticks; | 80 | int ticks; |
81 | int pid; | 81 | pid_t pid; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | /* | 84 | /* |
@@ -119,7 +119,8 @@ static void get_jiffy_counts(void) | |||
119 | static void do_stats(void) | 119 | static void do_stats(void) |
120 | { | 120 | { |
121 | procps_status_t *cur; | 121 | procps_status_t *cur; |
122 | int pid, total_time, i, last_i, n; | 122 | pid_t pid; |
123 | int total_time, i, last_i, n; | ||
123 | struct save_hist *new_hist; | 124 | struct save_hist *new_hist; |
124 | 125 | ||
125 | get_jiffy_counts(); | 126 | get_jiffy_counts(); |
@@ -328,9 +329,9 @@ static void display_status(int count, int scr_width) | |||
328 | else | 329 | else |
329 | sprintf(rss_str_buf, "%7ld", s->rss); | 330 | sprintf(rss_str_buf, "%7ld", s->rss); |
330 | USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu = div((s->pcpu*pcpu_scale) >> pcpu_shift, 10);) | 331 | USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu = div((s->pcpu*pcpu_scale) >> pcpu_shift, 10);) |
331 | col -= printf("\n%5d %-8s %s %s%6d%3u.%c" \ | 332 | col -= printf("\n%5u %-8s %s %s%6u%3u.%c" \ |
332 | USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE("%3u.%c") " ", | 333 | USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE("%3u.%c") " ", |
333 | s->pid, s->user, s->state, rss_str_buf, s->ppid, | 334 | (unsigned)s->pid, s->user, s->state, rss_str_buf, (unsigned)s->ppid, |
334 | USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,) | 335 | USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,) |
335 | pmem.quot, '0'+pmem.rem); | 336 | pmem.quot, '0'+pmem.rem); |
336 | if (col > 0) | 337 | if (col > 0) |