diff options
Diffstat (limited to 'toys/posix/kill.c')
-rw-r--r-- | toys/posix/kill.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/toys/posix/kill.c b/toys/posix/kill.c index c9de98ea..3c129b04 100644 --- a/toys/posix/kill.c +++ b/toys/posix/kill.c @@ -11,7 +11,7 @@ * * No Standard -USE_KILL(NEWTOY(kill, "?ls: ", TOYFLAG_BIN)) +USE_KILL(NEWTOY(kill, "?ls: ", TOYFLAG_BIN|TOYFLAG_MAYFORK)) USE_KILLALL5(NEWTOY(killall5, "?o*ls: [!lo][!ls]", TOYFLAG_SBIN)) config KILL @@ -65,12 +65,13 @@ void kill_main(void) if (FLAG(l)) { if (*args) { int signum = sig_to_num(*args); - char *s = NULL; + char *s = 0; if (signum>=0) s = num_to_sig(signum&127); if (isdigit(**args)) puts(s ? s : "UNKNOWN"); else printf("%d\n", signum); } else list_signals(); + return; } @@ -80,6 +81,7 @@ void kill_main(void) if (TT.s) { char *arg; int i = strtol(TT.s, &arg, 10); + if (!*arg) arg = num_to_sig(i); else arg = TT.s; @@ -106,7 +108,10 @@ void kill_main(void) sid = getsid(pid = getpid()); - if (!(dp = opendir("/proc"))) perror_exit("/proc"); + if (!(dp = opendir("/proc"))) { + free(olist); + perror_exit("/proc"); + } while ((entry = readdir(dp))) { int count, procpid, procsid; @@ -128,10 +133,8 @@ void kill_main(void) kill(procpid, signum); } - if (CFG_TOYBOX_FREE) { - closedir(dp); - free(olist); - } + closedir(dp); + free(olist); // is it kill? } else { |