[PATCH 3/4] support/shell-container.c: Add builtin kill
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Mar 24 19:42:23 GMT 2020
On 24/03/2020 16:37, DJ Delorie wrote:
> Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> writes:
>> +/* Emulate the "/bin/kill" command. Options are ignored. */
>
> "Options" meaning -TERM and the like? Because arguments aren't
> ignored...
Yes, SIGTERM is suffice to tst-system.
>
>> +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;
>> +}
>> +
>
> Ok.
>
>> + { "kill", kill_func },
>
> Ok. I draw the line at adding a mail reader, though ;-)
>
>> @@ -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);
>> }
>
> Ok.
>
> Reviewed-by: DJ Delorie <dj@redhat.com>
>
More information about the Libc-alpha
mailing list