From e4f2d064b0fcffc8897089e1c80e6e2d61b6805d Mon Sep 17 00:00:00 2001
From: Denis Vlasenko
Busybox execution starts with the main() function in applets/busybox.c, which sets the global variable applet_name to argv[0] and calls -run_applet_by_name() in applets/applets.c. That uses the applets[] array +run_applet_and_exit() in applets/applets.c. That uses the applets[] array (defined in include/busybox.h and filled out in include/applets.h) to transfer control to the appropriate APPLET_main() function (such as cat_main() or sed_main()). The individual applet takes it from there.
diff --git a/include/libbb.h b/include/libbb.h index 11fcd19f2..c3baf9e7c 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -675,7 +675,7 @@ const struct hwtype *get_hwntype(int type); struct bb_applet; extern const struct bb_applet *find_applet_by_name(const char *name); /* Returns only if applet is not found. */ -extern void run_applet_by_name(const char *name, int argc, char **argv); +extern void run_applet_and_exit(const char *name, int argc, char **argv); extern void run_current_applet_and_exit(int argc, char **argv) ATTRIBUTE_NORETURN; #endif diff --git a/scripts/individual b/scripts/individual index a09a5dc7a..e93ca5552 100755 --- a/scripts/individual +++ b/scripts/individual @@ -106,7 +106,7 @@ function buildit () gcc -Os -o build/$APPLET applets/individual.c $j \ `extra_libraries $APPFILT` libbb/libbb.a -Iinclude \ -DBUILD_INDIVIDUAL \ - '-Drun_applet_by_name(...)' '-Dfind_applet_by_name(...)=0' \ + '-Drun_applet_and_exit(...)' '-Dfind_applet_by_name(...)=0' \ -DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME} if [ $? -ne 0 ]; then diff --git a/shell/bbsh.c b/shell/bbsh.c index 06fd0131e..6bef3685a 100644 --- a/shell/bbsh.c +++ b/shell/bbsh.c @@ -165,7 +165,7 @@ static int run_pipeline(struct pipeline *line) int status; pid_t pid=fork(); if(!pid) { - run_applet_by_name(cmd->argv[0],cmd->argc,cmd->argv); + run_applet_and_exit(cmd->argv[0],cmd->argc,cmd->argv); execvp(cmd->argv[0],cmd->argv); printf("No %s",cmd->argv[0]); exit(1); diff --git a/shell/hush.c b/shell/hush.c index f6c69a221..3048d695a 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1123,7 +1123,7 @@ static void pseudo_exec(struct child_prog *child) /**/; optind = 1; debug_printf("running applet %s\n", name); - run_applet_by_name(name, argc_l, child->argv); + run_applet_and_exit(name, argc_l, child->argv); } #endif debug_printf("exec of %s\n", child->argv[0]); diff --git a/shell/lash.c b/shell/lash.c index 99e2b1f06..f91bec254 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -1170,7 +1170,7 @@ static int pseudo_exec(struct child_prog *child) for (argc_l = 0; *argv_l; argv_l++, argc_l++); optind = 1; - run_applet_by_name(child->argv[0], argc_l, child->argv); + run_applet_and_exit(child->argv[0], argc_l, child->argv); } execvp(child->argv[0], child->argv); diff --git a/shell/msh.c b/shell/msh.c index 0337a4f06..963e59446 100644 --- a/shell/msh.c +++ b/shell/msh.c @@ -3068,7 +3068,7 @@ static const char *rexecve(char *c, char **v, char **envp) optind = 1; if (find_applet_by_name(name)) { /* We have to exec here since we vforked. Running - * run_applet_by_name() won't work and bad things + * run_applet_and_exit() won't work and bad things * will happen. */ execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp); } -- 2.25.1