skill: fix command line with signal, again
Application of master patch d1d2ccf
Original by Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
1f8e41d019
commit
6586f9f9ce
6
kill.c
6
kill.c
@ -50,7 +50,7 @@ static void __attribute__ ((__noreturn__)) print_usage(FILE * out)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int signo, i, sigopt=0, loop=1;
|
||||
int signo, i, loop=1;
|
||||
long pid;
|
||||
int exitvalue = EXIT_SUCCESS;
|
||||
|
||||
@ -75,8 +75,6 @@ int main(int argc, char **argv)
|
||||
signo = skill_sig_option(&argc, argv);
|
||||
if (signo < 0)
|
||||
signo = SIGTERM;
|
||||
else
|
||||
sigopt++;
|
||||
|
||||
opterr=0; /* suppress errors on -123 */
|
||||
while (loop == 1 && (i = getopt_long(argc, argv, "l::Ls:hV", longopts, NULL)) != -1)
|
||||
@ -124,7 +122,7 @@ int main(int argc, char **argv)
|
||||
print_usage(stderr);
|
||||
}
|
||||
|
||||
argc -= optind + sigopt;
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
@ -200,17 +200,15 @@ const char *signal_number_to_name(int signo)
|
||||
|
||||
int skill_sig_option(int *argc, char **argv)
|
||||
{
|
||||
int i, nargs = *argc;
|
||||
int i;
|
||||
int signo = -1;
|
||||
for (i = 1; i < nargs; i++) {
|
||||
for (i = 1; i < *argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
signo = signal_name_to_number(argv[i] + 1);
|
||||
if (-1 < signo) {
|
||||
if (nargs - i) {
|
||||
nargs--;
|
||||
memmove(argv + i, argv + i + 1,
|
||||
sizeof(char *) * (nargs - i));
|
||||
}
|
||||
sizeof(char *) * (*argc - i));
|
||||
(*argc)--;
|
||||
return signo;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user