Commit 9ca2f35f authored by Craig Small's avatar Craig Small

kill: a better option parser

The previous commit would not work in newlib. Further investigation
found a better way of parsing this extra option using optind

References:
 commit 536cea32
parent 536cea32
Pipeline #6336097 passed with stage
in 3 minutes and 7 seconds
......@@ -422,7 +422,6 @@ static void __attribute__ ((__noreturn__))
int loop = 1;
long pid;
int exitvalue = EXIT_SUCCESS;
int optindex;
char *sig_option;
static const struct option longopts[] = {
......@@ -447,14 +446,14 @@ static void __attribute__ ((__noreturn__))
signo = SIGTERM;
opterr=0; /* suppress errors on -123 */
while (loop == 1 && (i = getopt_long(argc, argv, "l::Ls:hV", longopts, &optindex)) != -1)
while (loop == 1 && (i = getopt_long(argc, argv, "l::Ls:hV", longopts, NULL)) != -1)
switch (i) {
case 'l':
sig_option = NULL;
if (optarg) {
sig_option = optarg;
} else if (argv[optindex+1] != NULL && argv[optindex+1][0] != '-') {
sig_option = argv[optindex+1];
} else if (argv[optind] != NULL && argv[optind][0] != '-') {
sig_option = argv[optind];
}
if (sig_option) {
char *s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment