summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Heimpold2019-01-01 23:44:56 +0000
committerJohn Crispin2019-10-27 13:21:14 +0000
commit3e39fe539490e618e068358a68028fa33bf9e247 (patch)
tree5951ef3bf1f1a44974c24e0d4a3ad19469eb601d
parent5d6282906baf52258c080872fdc53a311ff5db88 (diff)
downloadprocd-3e39fe539490e618e068358a68028fa33bf9e247.tar.gz
procd: shift arguments for askfirst only once
In case we want to process an inittab item multiple times (e.g. in case of hotplugging) we must not shift the arguments for askfirst multiple times. So check whether we already did it. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
-rw-r--r--inittab.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/inittab.c b/inittab.c
index b67730c..1cfef2b 100644
--- a/inittab.c
+++ b/inittab.c
@@ -165,9 +165,12 @@ static void askfirst(struct init_action *a)
}
a->tout.cb = respawn;
- for (i = MAX_ARGS - 1; i >= 1; i--)
- a->argv[i] = a->argv[i - 1];
- a->argv[0] = ask;
+ /* shift arguments only if not yet done */
+ if (a->argv[0] != ask) {
+ for (i = MAX_ARGS - 1; i >= 1; i--)
+ a->argv[i] = a->argv[i - 1];
+ a->argv[0] = ask;
+ }
a->respawn = 500;
a->proc.cb = child_exit;
@@ -200,9 +203,12 @@ static void askconsole(struct init_action *a)
}
a->tout.cb = respawn;
- for (i = MAX_ARGS - 1; i >= 1; i--)
- a->argv[i] = a->argv[i - 1];
- a->argv[0] = ask;
+ /* shift arguments only if not yet done */
+ if (a->argv[0] != ask) {
+ for (i = MAX_ARGS - 1; i >= 1; i--)
+ a->argv[i] = a->argv[i - 1];
+ a->argv[0] = ask;
+ }
a->respawn = 500;
a->proc.cb = child_exit;