The user program expects 'optind' to be reset and for 'argv' and 'argc'
to include the program name as the first argument variable.
Note: our mmap()/mprotect()-based snapshotting does not snapshot this
'optind' global, so user-progs that use optarg() functionality might
fail.
break;
}
}
- (*argc) -= optind;
- (*argv) += optind;
+ (*argv)[optind - 1] = (*argv)[0];
+ (*argc) -= (optind - 1);
+ (*argv) += (optind - 1);
+ optind = 1;
if (error)
print_usage(params);