aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb/killall.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
committerRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
commit7aa651a6a4496d848f86de9b1e6b3a003256a01f (patch)
tree6995fb4b7cc2e90a6706b0239ebaf95d9dbab530 /toys/lsb/killall.c
parent571b0706cce45716126776d0ad0f6ac65f4586e3 (diff)
downloadtoybox-7aa651a6a4496d848f86de9b1e6b3a003256a01f.tar.gz
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
Diffstat (limited to 'toys/lsb/killall.c')
-rw-r--r--toys/lsb/killall.c79
1 files changed, 38 insertions, 41 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c
index ec9df62e..7883c53d 100644
--- a/toys/lsb/killall.c
+++ b/toys/lsb/killall.c
@@ -1,6 +1,4 @@
-/* vi: set sw=4 ts=4:
- *
- * killall.c - Send signal (default: TERM) to all processes with given names.
+/* killall.c - Send signal (default: TERM) to all processes with given names.
*
* Copyright 2012 Andreas Heck <aheck@gmx.de>
*
@@ -9,68 +7,67 @@
USE_KILLALL(NEWTOY(killall, "<1?lq", TOYFLAG_USR|TOYFLAG_BIN))
config KILLALL
- bool "killall"
- default y
- help
- usage: killall [-l] [-q] [-SIG] PROCESS_NAME...
+ bool "killall"
+ default y
+ help
+ usage: killall [-l] [-q] [-SIG] PROCESS_NAME...
- Send a signal (default: TERM) to all processes with the given names.
+ Send a signal (default: TERM) to all processes with the given names.
- -l print list of all available signals
- -q don't print any warnings or error messages
+ -l print list of all available signals
+ -q don't print any warnings or error messages
*/
#define FOR_killall
#include "toys.h"
GLOBALS(
- int signum;
+ int signum;
)
static void kill_process(pid_t pid)
{
- int ret;
+ int ret;
- toys.exitval = 0;
- ret = kill(pid, TT.signum);
+ toys.exitval = 0;
+ ret = kill(pid, TT.signum);
- if (ret == -1 && !(toys.optflags & FLAG_q)) perror("kill");
+ if (ret == -1 && !(toys.optflags & FLAG_q)) perror("kill");
}
void killall_main(void)
{
- char **names;
+ char **names;
- if (toys.optflags & FLAG_l) {
- sig_to_num(NULL);
- return;
- }
+ if (toys.optflags & FLAG_l) {
+ sig_to_num(NULL);
+ return;
+ }
- TT.signum = SIGTERM;
- toys.exitval++;
+ TT.signum = SIGTERM;
+ toys.exitval++;
- if (!*toys.optargs) {
- toys.exithelp = 1;
- error_exit("Process name missing!");
- }
+ if (!*toys.optargs) {
+ toys.exithelp = 1;
+ error_exit("Process name missing!");
+ }
- names = toys.optargs;
+ names = toys.optargs;
- if (**names == '-') {
- if (0 > (TT.signum = sig_to_num((*names)+1))) {
- if (toys.optflags & FLAG_q) exit(1);
- error_exit("Invalid signal");
- }
- names++;
+ if (**names == '-') {
+ if (0 > (TT.signum = sig_to_num((*names)+1))) {
+ if (toys.optflags & FLAG_q) exit(1);
+ error_exit("Invalid signal");
+ }
+ names++;
- if (!*names) {
- toys.exithelp++;
- error_exit("Process name missing!");
- }
- }
+ if (!*names) {
+ toys.exithelp++;
+ error_exit("Process name missing!");
+ }
+ }
- for_each_pid_with_name_in(names, kill_process);
+ for_each_pid_with_name_in(names, kill_process);
- if (toys.exitval && !(toys.optflags & FLAG_q))
- error_exit("No such process");
+ if (toys.exitval && !(toys.optflags & FLAG_q)) error_exit("No such process");
}