diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-12 20:07:53 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-12 20:07:53 +0000 |
commit | 9bc80d7062a01aa310be0729c095ba6b652c4735 (patch) | |
tree | 9ee8208bc63a09ce1fc9031ffc7123b06ce77b9c | |
parent | 4a9ca13fe7587314aa55a800c86e20fc21d8f2b1 (diff) | |
download | busybox-w32-9bc80d7062a01aa310be0729c095ba6b652c4735.tar.gz busybox-w32-9bc80d7062a01aa310be0729c095ba6b652c4735.tar.bz2 busybox-w32-9bc80d7062a01aa310be0729c095ba6b652c4735.zip |
ash: add FEATURE_SH_NOFORK support
-rw-r--r-- | shell/Config.in | 17 | ||||
-rw-r--r-- | shell/ash.c | 18 |
2 files changed, 35 insertions, 0 deletions
diff --git a/shell/Config.in b/shell/Config.in index 40e0217f4..94ffa09f8 100644 --- a/shell/Config.in +++ b/shell/Config.in | |||
@@ -287,6 +287,23 @@ config FEATURE_SH_STANDALONE | |||
287 | # that exact location with that exact name, this option will not work at | 287 | # that exact location with that exact name, this option will not work at |
288 | # all. | 288 | # all. |
289 | 289 | ||
290 | config FEATURE_SH_NOFORK | ||
291 | bool "Run 'nofork' applets directly" | ||
292 | default n | ||
293 | depends on (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS | ||
294 | help | ||
295 | This option causes busybox shells [currently only ash] | ||
296 | to not execute typical fork/exec/wait sequence, but call <applet>_main | ||
297 | directly, if possible. (Sometimes it is not possible: for example, | ||
298 | this is not possible in pipes). | ||
299 | |||
300 | This will be done only for some applets (those which are marked | ||
301 | NOFORK in include/applets.h). | ||
302 | |||
303 | This may significantly speed up some shell scripts. | ||
304 | |||
305 | This feature is relatively new. Use with care. | ||
306 | |||
290 | config CTTYHACK | 307 | config CTTYHACK |
291 | bool "cttyhack" | 308 | bool "cttyhack" |
292 | default n | 309 | default n |
diff --git a/shell/ash.c b/shell/ash.c index 0872e681a..cc61401d1 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -8747,6 +8747,24 @@ evalcommand(union node *cmd, int flags) | |||
8747 | /* Execute the command. */ | 8747 | /* Execute the command. */ |
8748 | switch (cmdentry.cmdtype) { | 8748 | switch (cmdentry.cmdtype) { |
8749 | default: | 8749 | default: |
8750 | |||
8751 | #if ENABLE_FEATURE_SH_NOFORK | ||
8752 | { | ||
8753 | /* TODO: don't rerun find_applet_by_name, find_command | ||
8754 | * already did it. Make it save applet_no somewhere */ | ||
8755 | int applet_no = find_applet_by_name(argv[0]); | ||
8756 | if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) { | ||
8757 | struct nofork_save_area nofork_save; | ||
8758 | |||
8759 | listsetvar(varlist.list, VEXPORT|VSTACK); | ||
8760 | save_nofork_data(&nofork_save); | ||
8761 | /* run <applet>_main(), then restore nofork_save_area */ | ||
8762 | exitstatus = run_nofork_applet_prime(&nofork_save, applet_no, argv) & 0xff; | ||
8763 | break; | ||
8764 | } | ||
8765 | } | ||
8766 | #endif | ||
8767 | |||
8750 | /* Fork off a child process if necessary. */ | 8768 | /* Fork off a child process if necessary. */ |
8751 | if (!(flags & EV_EXIT) || trap[0]) { | 8769 | if (!(flags & EV_EXIT) || trap[0]) { |
8752 | INT_OFF; | 8770 | INT_OFF; |