public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tulio Magno Quites Machado Filho <tuliom@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/ibm/2.30/master] support/shell-container.c: Add builtin kill Date: Tue, 12 May 2020 18:43:43 +0000 (GMT) [thread overview] Message-ID: <20200512184343.B84E3386F02B@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=42766b3db2c895be02404dc89995412e841f05b7 commit 42766b3db2c895be02404dc89995412e841f05b7 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Tue Mar 24 15:47:13 2020 -0300 support/shell-container.c: Add builtin kill No options supported. Reviewed-by: DJ Delorie <dj@redhat.com> (cherry picked from commit 1c17100c43c0913ec94f3bcc966bf3792236c690) Diff: --- support/shell-container.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/support/shell-container.c b/support/shell-container.c index 99a0ff7ca5..51b01dce0d 100644 --- a/support/shell-container.c +++ b/support/shell-container.c @@ -147,6 +147,25 @@ exit_func (char **argv) return 0; } +/* Emulate the "/bin/kill" command. Options are ignored. */ +static int +kill_func (char **argv) +{ + int signum = SIGTERM; + int i; + + for (i = 0; argv[i]; i++) + { + pid_t pid; + if (strcmp (argv[i], "$$") == 0) + pid = getpid (); + else + pid = atoi (argv[i]); + kill (pid, signum); + } + return 0; +} + /* This is a list of all the built-in commands we understand. */ static struct { const char *name; @@ -156,6 +175,7 @@ static struct { { "echo", echo_func }, { "cp", copy_func }, { "exit", exit_func }, + { "kill", kill_func }, { NULL, NULL } }; @@ -264,6 +284,11 @@ run_command_array (char **argv) if (rv) exit (rv); } + else if (WIFSIGNALED (status)) + { + int sig = WTERMSIG (status); + raise (sig); + } else exit (1); }
reply other threads:[~2020-05-12 18:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200512184343.B84E3386F02B@sourceware.org \ --to=tuliom@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).