aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/kill.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-01-01 13:02:20 -0600
committerRob Landley <rob@landley.net>2020-01-01 13:02:20 -0600
commit9c52df1131cf208df3e73cb440485d3673c6491a (patch)
tree9f92a13560c9dac0282c97d496cd85491d04bd63 /toys/posix/kill.c
parent7a9073f942b83d12d24415a92428e02aeb561a08 (diff)
downloadtoybox-9c52df1131cf208df3e73cb440485d3673c6491a.tar.gz
Add MAYFORK to more pseudo-builtins.
This doesn't (yet) add shell builtin awareness to time, kill, or pwd, just lets them run in the shell process.
Diffstat (limited to 'toys/posix/kill.c')
-rw-r--r--toys/posix/kill.c17
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 {