int run_nofork_applet(int applet_no, char **argv) FAST_FUNC;
#ifndef BUILD_INDIVIDUAL
extern int find_applet_by_name(const char *name) FAST_FUNC;
-extern void run_applet_no_and_exit(int a, char **argv) NORETURN FAST_FUNC;
+extern void run_applet_no_and_exit(int a, const char *name, char **argv) NORETURN FAST_FUNC;
#endif
/* Helpers for daemonization.
# endif
# if NUM_APPLETS > 0
-void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
+void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv)
{
int argc = string_array_len(argv);
/* Reinit some shared global data */
xfunc_error_retval = EXIT_FAILURE;
- applet_name = bb_get_last_path_component_nostrip(argv[0]);
+ /*
+ * We do not use argv[0]: do not want to repeat massaging of
+ * "-/sbin/halt" -> "halt", for example.
+ */
+ applet_name = name;
/* Special case. POSIX says "test --help"
* should be no different from e.g. "test --foo".
{
int applet = find_applet_by_name(name);
if (applet >= 0)
- run_applet_no_and_exit(applet, argv);
+ run_applet_no_and_exit(applet, name, argv);
}
# endif
* as of yet (and that should probably always stay true).
*/
/* xfunc_error_retval and applet_name are init by: */
- run_applet_no_and_exit(a, argv);
+ run_applet_no_and_exit(a, argv[0], argv);
}
# endif
}
clearenv();
while (*envp)
putenv(*envp++);
- run_applet_no_and_exit(applet_no, argv);
+ run_applet_no_and_exit(applet_no, cmd, argv);
}
/* re-exec ourselves with the new arguments */
execve(bb_busybox_exec_path, argv, envp);
/* Do not leak open fds from opened script files etc */
close_all_FILE_list();
debug_printf_exec("running applet '%s'\n", argv[0]);
- run_applet_no_and_exit(a, argv);
+ run_applet_no_and_exit(a, argv[0], argv);
}
# endif
/* Re-exec ourselves */