aboutsummaryrefslogtreecommitdiff
path: root/procps/kill.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-01 09:16:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-01 09:16:49 +0000
commit35fb51272863c8723a40e59d2024c7f4c9ec8946 (patch)
treea97deb26bca43e394a603840039846cd9d89cae9 /procps/kill.c
parentd3ada3228551e2556afb9de6d3126fd016df1fb1 (diff)
downloadbusybox-w32-35fb51272863c8723a40e59d2024c7f4c9ec8946.tar.gz
busybox-w32-35fb51272863c8723a40e59d2024c7f4c9ec8946.tar.bz2
busybox-w32-35fb51272863c8723a40e59d2024c7f4c9ec8946.zip
PID should be stored in pid_t, not int or long.
find_pid_by_name() was returning 0 or -1 in last array element, but -1 was never checked. We can use just 0 intead.
Diffstat (limited to 'procps/kill.c')
-rw-r--r--procps/kill.c30
1 files changed, 16 insertions, 14 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;