diff options
author | Ron Yorston <rmy@pobox.com> | 2024-08-19 08:06:19 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-08-19 08:06:19 +0100 |
commit | 4b7b4a960bab5b3e331e130b257fe8280fd9da43 (patch) | |
tree | 78aa6a26f38c4a279ab7310992e2259be3f5ece5 /win32 | |
parent | b21899038683bd646446d3db9e84f64ea669d2ed (diff) | |
download | busybox-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 'win32')
-rw-r--r-- | win32/process.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/win32/process.c b/win32/process.c index 097a1d71c..e3ce95ca0 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -53,14 +53,7 @@ pid_t mingw_wait3(pid_t pid, int *status, int options, struct rusage *rusage) | |||
53 | return -1; | 53 | return -1; |
54 | } | 54 | } |
55 | 55 | ||
56 | typedef struct { | 56 | int FAST_FUNC |
57 | char *path; | ||
58 | char *name; | ||
59 | char *opts; | ||
60 | char buf[100]; | ||
61 | } interp_t; | ||
62 | |||
63 | static int | ||
64 | parse_interpreter(const char *cmd, interp_t *interp) | 57 | parse_interpreter(const char *cmd, interp_t *interp) |
65 | { | 58 | { |
66 | char *path, *t; | 59 | char *path, *t; |