aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/kill.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/posix/kill.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/posix/kill.c')
-rw-r--r--toys/posix/kill.c87
1 files changed, 42 insertions, 45 deletions
diff --git a/toys/posix/kill.c b/toys/posix/kill.c
index 7810b899..2d1606b4 100644
--- a/toys/posix/kill.c
+++ b/toys/posix/kill.c
@@ -1,6 +1,4 @@
-/* vi: set sw=4 ts=4:
- *
- * kill.c - a program to send signals to processes
+/* kill.c - a program to send signals to processes
*
* Copyright 2012 Daniel Walter <d.walter@0x90.at>
*
@@ -9,65 +7,64 @@
USE_KILL(NEWTOY(kill, "?s: l", TOYFLAG_BIN))
config KILL
- bool "kill"
- default y
- help
- usage: kill [-l [SIGNAL] | -s SIGNAL | -SIGNAL] pid...
-
- Send a signal to a process
+ bool "kill"
+ default y
+ help
+ usage: kill [-l [SIGNAL] | -s SIGNAL | -SIGNAL] pid...
+ Send a signal to a process
*/
#define FOR_kill
#include "toys.h"
GLOBALS(
- char *signame;
+ char *signame;
)
void kill_main(void)
{
- int signum;
- char *tmp, **args = toys.optargs;
- pid_t pid;
+ int signum;
+ char *tmp, **args = toys.optargs;
+ pid_t pid;
- // list signal(s)
- if (toys.optflags & FLAG_l) {
- if (*args) {
- int signum = sig_to_num(*args);
- char *s = NULL;
+ // list signal(s)
+ if (toys.optflags & FLAG_l) {
+ if (*args) {
+ int signum = sig_to_num(*args);
+ char *s = NULL;
- if (signum>=0) s = num_to_sig(signum&127);
- puts(s ? s : "UNKNOWN");
- } else sig_to_num(NULL);
- return;
- }
+ if (signum>=0) s = num_to_sig(signum&127);
+ puts(s ? s : "UNKNOWN");
+ } else sig_to_num(NULL);
+ return;
+ }
- // signal must come before pids, so "kill -9 -1" isn't confusing.
+ // signal must come before pids, so "kill -9 -1" isn't confusing.
- if (!TT.signame && *args && **args=='-') TT.signame=*(args++)+1;
- if (TT.signame) {
- char *arg;
- int i = strtol(TT.signame, &arg, 10);
- if (!*arg) arg = num_to_sig(i);
- else arg = TT.signame;
+ if (!TT.signame && *args && **args=='-') TT.signame=*(args++)+1;
+ if (TT.signame) {
+ char *arg;
+ int i = strtol(TT.signame, &arg, 10);
+ if (!*arg) arg = num_to_sig(i);
+ else arg = TT.signame;
- if (!arg || -1 == (signum = sig_to_num(arg)))
- error_exit("Unknown signal '%s'", arg);
- } else signum = SIGTERM;
+ if (!arg || -1 == (signum = sig_to_num(arg)))
+ error_exit("Unknown signal '%s'", arg);
+ } else signum = SIGTERM;
- if (!*args) {
- toys.exithelp++;
- error_exit("missing argument");
- }
+ if (!*args) {
+ toys.exithelp++;
+ error_exit("missing argument");
+ }
- while (*args) {
- char *arg = *(args++);
+ while (*args) {
+ char *arg = *(args++);
- pid = strtol(arg, &tmp, 10);
- if (*tmp || kill(pid, signum) < 0) {
- error_msg("unknown pid '%s'", arg);
- toys.exitval = EXIT_FAILURE;
- }
- }
+ pid = strtol(arg, &tmp, 10);
+ if (*tmp || kill(pid, signum) < 0) {
+ error_msg("unknown pid '%s'", arg);
+ toys.exitval = EXIT_FAILURE;
+ }
+ }
}