Mercurial > hg > toybox
view toys/posix/kill.c @ 818:264b9da809df
Simplify license text, as mentioned on the mailing list.
Reasoning: it was never my intent to require anybody to copy license
text into another project if they cut and pasted something out of
toybox. The "permission for any purpose" is as close to public domain
as you can get in our current screwed up legal system without making
people uncomfortable the _other_ way. (Besides, my initial reading of
that was "all copies of the source code" but that's not what it says,
and somebody pointed out that Android has "show license text" options
because paranoid lawyers think that sort of thing applies to the BINARY
version, which is nuts.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 14 Mar 2013 09:02:37 -0500 |
parents | 6cc69be43c42 |
children | cae43f3cfff4 |
line wrap: on
line source
/* kill.c - a program to send signals to processes * * Copyright 2012 Daniel Walter <d.walter@0x90.at> * * See http://opengroup.org/onlinepubs/9699919799/utilities/kill.html 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 */ #define FOR_kill #include "toys.h" GLOBALS( char *signame; ) void kill_main(void) { 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; 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. 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 (!*args) { toys.exithelp++; error_exit("missing argument"); } while (*args) { char *arg = *(args++); pid = strtol(arg, &tmp, 10); if (*tmp || kill(pid, signum) < 0) error_msg("unknown pid '%s'", arg); } }