Fix indentation. Support killall -q, for pcmcia-cs

-Erik
This commit is contained in:
Eric Andersen 2002-07-23 23:45:11 +00:00
parent f2f26e7fdd
commit 80cd3cfdbc

View File

@ -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,6 +58,11 @@ extern int kill_main(int argc, char **argv)
while (argc > 0 && **argv == '-') {
while (*++(*argv)) {
switch (**argv) {
#ifdef CONFIG_KILLALL
case 'q':
quiet++;
break;
#endif
case 'l':
if(argc>1) {
for(argv++; *argv; argv++) {
@ -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,15 +127,24 @@ extern int kill_main(int argc, char **argv)
pidList = find_pid_by_name( *argv);
if (!pidList || *pidList<=0) {
all_found = FALSE;
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)
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
* upon exit, so we can save a byte or two */