Blame SOURCES/glibc-rh2065588-12.patch
|
|
00c0d4 |
commit 1c17100c43c0913ec94f3bcc966bf3792236c690
|
|
|
00c0d4 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
00c0d4 |
Date: Tue Mar 24 15:47:13 2020 -0300
|
|
|
00c0d4 |
|
|
|
00c0d4 |
support/shell-container.c: Add builtin kill
|
|
|
00c0d4 |
|
|
|
00c0d4 |
No options supported.
|
|
|
00c0d4 |
|
|
|
00c0d4 |
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
|
00c0d4 |
|
|
|
00c0d4 |
diff --git a/support/shell-container.c b/support/shell-container.c
|
|
|
00c0d4 |
index aeaf6d2733abce61..3869e14683fb74dd 100644
|
|
|
00c0d4 |
--- a/support/shell-container.c
|
|
|
00c0d4 |
+++ b/support/shell-container.c
|
|
|
00c0d4 |
@@ -147,6 +147,25 @@ exit_func (char **argv)
|
|
|
00c0d4 |
return 0;
|
|
|
00c0d4 |
}
|
|
|
00c0d4 |
|
|
|
00c0d4 |
+/* Emulate the "/bin/kill" command. Options are ignored. */
|
|
|
00c0d4 |
+static int
|
|
|
00c0d4 |
+kill_func (char **argv)
|
|
|
00c0d4 |
+{
|
|
|
00c0d4 |
+ int signum = SIGTERM;
|
|
|
00c0d4 |
+ int i;
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+ for (i = 0; argv[i]; i++)
|
|
|
00c0d4 |
+ {
|
|
|
00c0d4 |
+ pid_t pid;
|
|
|
00c0d4 |
+ if (strcmp (argv[i], "$$") == 0)
|
|
|
00c0d4 |
+ pid = getpid ();
|
|
|
00c0d4 |
+ else
|
|
|
00c0d4 |
+ pid = atoi (argv[i]);
|
|
|
00c0d4 |
+ kill (pid, signum);
|
|
|
00c0d4 |
+ }
|
|
|
00c0d4 |
+ return 0;
|
|
|
00c0d4 |
+}
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
/* This is a list of all the built-in commands we understand. */
|
|
|
00c0d4 |
static struct {
|
|
|
00c0d4 |
const char *name;
|
|
|
00c0d4 |
@@ -156,6 +175,7 @@ static struct {
|
|
|
00c0d4 |
{ "echo", echo_func },
|
|
|
00c0d4 |
{ "cp", copy_func },
|
|
|
00c0d4 |
{ "exit", exit_func },
|
|
|
00c0d4 |
+ { "kill", kill_func },
|
|
|
00c0d4 |
{ NULL, NULL }
|
|
|
00c0d4 |
};
|
|
|
00c0d4 |
|
|
|
00c0d4 |
@@ -264,6 +284,11 @@ run_command_array (char **argv)
|
|
|
00c0d4 |
if (rv)
|
|
|
00c0d4 |
exit (rv);
|
|
|
00c0d4 |
}
|
|
|
00c0d4 |
+ else if (WIFSIGNALED (status))
|
|
|
00c0d4 |
+ {
|
|
|
00c0d4 |
+ int sig = WTERMSIG (status);
|
|
|
00c0d4 |
+ raise (sig);
|
|
|
00c0d4 |
+ }
|
|
|
00c0d4 |
else
|
|
|
00c0d4 |
exit (1);
|
|
|
00c0d4 |
}
|