summaryrefslogtreecommitdiff
path: root/procps/kill.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-11-01 09:16:49 +0000
committerDenis Vlasenko2006-11-01 09:16:49 +0000
commit35fb51272863c8723a40e59d2024c7f4c9ec8946 (patch)
treea97deb26bca43e394a603840039846cd9d89cae9 /procps/kill.c
parentd3ada3228551e2556afb9de6d3126fd016df1fb1 (diff)
downloadbusybox-35fb51272863c8723a40e59d2024c7f4c9ec8946.zip
busybox-35fb51272863c8723a40e59d2024c7f4c9ec8946.tar.gz
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 b29f61b..f22bdbe 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -103,31 +103,31 @@ do_it_now:
}
/* Pid or name required for kill/killall */
- if (argc<1)
+ if (argc < 1)
bb_show_usage();
if (killall) {
/* Looks like they want to do a killall. Do that */
pid = getpid();
while (arg) {
- long* pidList;
+ pid_t* pidList;
pidList = find_pid_by_name(arg);
- if (!pidList || *pidList<=0) {
+ if (*pidList == 0) {
errors++;
if (!quiet)
bb_error_msg("%s: no process killed", arg);
} else {
- long *pl;
+ pid_t *pl;
- for (pl = pidList; *pl!=0; pl++) {
- if (*pl==pid)
+ for (pl = pidList; *pl; pl++) {
+ if (*pl == pid)
continue;
- if (kill(*pl, signo)!=0) {
- errors++;
- if (!quiet)
- bb_perror_msg("cannot kill pid %ld", *pl);
- }
+ if (kill(*pl, signo) == 0)
+ continue;
+ errors++;
+ if (!quiet)
+ bb_perror_msg("cannot kill pid %u", (unsigned)*pl);
}
}
free(pidList);
@@ -138,12 +138,14 @@ do_it_now:
/* Looks like they want to do a kill. Do that */
while (arg) {
- if (!isdigit(arg[0]) && arg[0]!='-')
+ /* Huh?
+ if (!isdigit(arg[0]) && arg[0] != '-')
bb_error_msg_and_die("bad pid '%s'", arg);
+ */
pid = xatou(arg);
/* FIXME: better overflow check? */
- if (kill(pid, signo)!=0) {
- bb_perror_msg("cannot kill pid %ld", (long)pid);
+ if (kill(pid, signo) != 0) {
+ bb_perror_msg("cannot kill pid %u", (unsigned)pid);
errors++;
}
arg = *++argv;