mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
support/shell-container.c: Add builtin kill
No options supported. Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
@@ -147,6 +147,25 @@ exit_func (char **argv)
|
|||||||
return 0;
|
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. */
|
/* This is a list of all the built-in commands we understand. */
|
||||||
static struct {
|
static struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
@@ -156,6 +175,7 @@ static struct {
|
|||||||
{ "echo", echo_func },
|
{ "echo", echo_func },
|
||||||
{ "cp", copy_func },
|
{ "cp", copy_func },
|
||||||
{ "exit", exit_func },
|
{ "exit", exit_func },
|
||||||
|
{ "kill", kill_func },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -264,6 +284,11 @@ run_command_array (char **argv)
|
|||||||
if (rv)
|
if (rv)
|
||||||
exit (rv);
|
exit (rv);
|
||||||
}
|
}
|
||||||
|
else if (WIFSIGNALED (status))
|
||||||
|
{
|
||||||
|
int sig = WTERMSIG (status);
|
||||||
|
raise (sig);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user