aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-08-19 08:06:19 +0100
committerRon Yorston <rmy@pobox.com>2024-08-19 08:06:19 +0100
commit4b7b4a960bab5b3e331e130b257fe8280fd9da43 (patch)
tree78aa6a26f38c4a279ab7310992e2259be3f5ece5 /include
parentb21899038683bd646446d3db9e84f64ea669d2ed (diff)
downloadbusybox-w32-4b7b4a960bab5b3e331e130b257fe8280fd9da43.tar.gz
busybox-w32-4b7b4a960bab5b3e331e130b257fe8280fd9da43.tar.bz2
busybox-w32-4b7b4a960bab5b3e331e130b257fe8280fd9da43.zip
ash: optimise running of scripts
The BusyBox shell detects certain cases where forking a command is unnecessary (last command in a script or subshell, for example) and calls execve(2) instead. This doesn't help in the Windows port because execve(2) is implemented by creating a process. There is one case where it is possible to apply this optimisation: if the command is a script and the script interpreter is an applet. - Have evalcommand() pass a flag to indicate this situation to shellexec(). Also, allocate two spare elements before the start of the argv array. - If the flag is TRUE shellexec() passes the shell's PATH variable down to tryexec() so it can perform a test for applet override. - If tryexec() finds that all the necessary conditions apply it can run a script by directly invoking the interpreter's main(). Adds 192-224 bytes.
Diffstat (limited to 'include')
-rw-r--r--include/mingw.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h
index adb810ec5..ed7884e39 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -566,6 +566,14 @@ int utimes(const char *file_name, const struct timeval times[2]);
566#define is_unc_path(x) (strlen(x) > 4 && is_dir_sep(x[0]) && \ 566#define is_unc_path(x) (strlen(x) > 4 && is_dir_sep(x[0]) && \
567 is_dir_sep(x[1]) && !is_dir_sep(x[2])) 567 is_dir_sep(x[1]) && !is_dir_sep(x[2]))
568 568
569typedef struct {
570 char *path;
571 char *name;
572 char *opts;
573 char buf[100];
574} interp_t;
575
576int FAST_FUNC parse_interpreter(const char *cmd, interp_t *interp);
569char ** FAST_FUNC grow_argv(char **argv, int n); 577char ** FAST_FUNC grow_argv(char **argv, int n);
570pid_t FAST_FUNC mingw_spawn(char **argv); 578pid_t FAST_FUNC mingw_spawn(char **argv);
571intptr_t FAST_FUNC mingw_spawn_detach(char **argv); 579intptr_t FAST_FUNC mingw_spawn_detach(char **argv);