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