aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-07-23 23:45:11 +0000
committerEric Andersen <andersen@codepoet.org>2002-07-23 23:45:11 +0000
commit80cd3cfdbc924b1a032b0634be8930af3daf791f (patch)
tree68e6b17be6a05a9a75eb69984ffa8c5d6ec2f3e3
parentf2f26e7fdddfb92a8ef3654e14092dcbe3420331 (diff)
downloadbusybox-80cd3cfdbc924b1a032b0634be8930af3daf791f.tar.gz
Fix indentation. Support killall -q, for pcmcia-cs
-Erik
-rw-r--r--procps/kill.c88
1 files changed, 52 insertions, 36 deletions
diff --git a/procps/kill.c b/procps/kill.c
index ff00ea875..5f2f6618f 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -38,7 +38,7 @@ static const int KILLALL = 1;
extern int kill_main(int argc, char **argv)
{
- int whichApp, sig = SIGTERM;
+ int whichApp, sig = SIGTERM, quiet;
const char *name;
#ifdef CONFIG_KILLALL
@@ -48,6 +48,7 @@ extern int kill_main(int argc, char **argv)
whichApp = KILL;
#endif
+ quiet=0;
argc--;
argv++;
/* Parse any options */
@@ -57,44 +58,49 @@ extern int kill_main(int argc, char **argv)
while (argc > 0 && **argv == '-') {
while (*++(*argv)) {
switch (**argv) {
- case 'l':
- if(argc>1) {
- for(argv++; *argv; argv++) {
- name = u_signal_names(*argv, &sig, -1);
- if(name!=NULL)
- printf("%s\n", name);
- }
- } else {
- int col = 0;
- for(sig=1; sig < NSIG; sig++) {
- name = u_signal_names(0, &sig, 1);
- if(name==NULL) /* unnamed */
- continue;
- col += printf("%2d) %-16s", sig, name);
- if (col > 60) {
- printf("\n");
- col = 0;
+#ifdef CONFIG_KILLALL
+ case 'q':
+ quiet++;
+ break;
+#endif
+ case 'l':
+ if(argc>1) {
+ for(argv++; *argv; argv++) {
+ name = u_signal_names(*argv, &sig, -1);
+ if(name!=NULL)
+ printf("%s\n", name);
}
- }
- printf("\n");
- }
- return EXIT_SUCCESS;
- case '-':
- show_usage();
- default:
- name = u_signal_names(*argv, &sig, 0);
- if(name==NULL)
- error_msg_and_die( "bad signal name: %s", *argv);
- argc--;
- argv++;
- goto do_it_now;
+ } else {
+ int col = 0;
+ for(sig=1; sig < NSIG; sig++) {
+ name = u_signal_names(0, &sig, 1);
+ if(name==NULL) /* unnamed */
+ continue;
+ col += printf("%2d) %-16s", sig, name);
+ if (col > 60) {
+ printf("\n");
+ col = 0;
}
+ }
+ printf("\n");
+ }
+ return EXIT_SUCCESS;
+ case '-':
+ show_usage();
+ default:
+ name = u_signal_names(*argv, &sig, 0);
+ if(name==NULL)
+ error_msg_and_die( "bad signal name: %s", *argv);
+ argc--;
+ argv++;
+ goto do_it_now;
+ }
argc--;
argv++;
}
}
- do_it_now:
+do_it_now:
if (whichApp == KILL) {
/* Looks like they want to do a kill. Do that */
@@ -104,8 +110,9 @@ extern int kill_main(int argc, char **argv)
if (!isdigit(**argv))
perror_msg_and_die( "Bad PID");
pid = strtol(*argv, NULL, 0);
- if (kill(pid, sig) != 0)
+ if (kill(pid, sig) != 0) {
perror_msg_and_die( "Could not kill pid '%d'", pid);
+ }
argv++;
}
}
@@ -120,14 +127,23 @@ extern int kill_main(int argc, char **argv)
pidList = find_pid_by_name( *argv);
if (!pidList || *pidList<=0) {
all_found = FALSE;
- error_msg_and_die( "%s: no process killed", *argv);
+ if (quiet) {
+ exit(EXIT_FAILURE);
+ } else {
+ error_msg_and_die( "%s: no process killed", *argv);
+ }
}
for(; pidList && *pidList!=0; pidList++) {
if (*pidList==myPid)
continue;
- if (kill(*pidList, sig) != 0)
- perror_msg_and_die( "Could not kill pid '%d'", *pidList);
+ if (kill(*pidList, sig) != 0) {
+ if (quiet) {
+ exit(EXIT_FAILURE);
+ } else {
+ perror_msg_and_die( "Could not kill pid '%d'", *pidList);
+ }
+ }
}
/* Note that we don't bother to free the memory
* allocated in find_pid_by_name(). It will be freed