summaryrefslogtreecommitdiff
path: root/src/shutdown/shutdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shutdown/shutdown.c')
-rw-r--r--src/shutdown/shutdown.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c
index 42111d2772..5dee1b3a92 100644
--- a/src/shutdown/shutdown.c
+++ b/src/shutdown/shutdown.c
@@ -75,6 +75,10 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 1);
assert(argv);
+ /* Resetting to 0 forces the invocation of an internal initialization routine of getopt_long()
+ * that checks for GNU extensions in optstring ('-' or '+' at the beginning). */
+ optind = 0;
+
/* "-" prevents getopt from permuting argv[] and moving the verb away
* from argv[1]. Our interface to initrd promises it'll be there. */
while ((c = getopt_long(argc, argv, "-", options, NULL)) >= 0)