diff options
author | Ron Yorston <rmy@pobox.com> | 2020-06-01 08:43:17 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-06-01 08:43:17 +0100 |
commit | 3c5995713d91df7b6f803b34e43df188646b0676 (patch) | |
tree | 8e00d001cb509aa1f448cebdfb5d12eb9d743c18 | |
parent | f81fcc84134ab2f29816dbfaf2e5af9ee62d2691 (diff) | |
download | busybox-w32-3c5995713d91df7b6f803b34e43df188646b0676.tar.gz busybox-w32-3c5995713d91df7b6f803b34e43df188646b0676.tar.bz2 busybox-w32-3c5995713d91df7b6f803b34e43df188646b0676.zip |
ash: simplify spawning during forkshell
spawn_forkshell() uses mingw_spawn_proc() to start the child shell.
mingw_spawn_proc() then calls mingw_spawn_1() which determines
that "sh" is an applet, thus calling mingw_spawn_applet() which
finally calls spawnveq().
Not only is this convoluted it also won't work if PREFER_APPLETS
and SH_STANDALONE aren't enabled.
Simplify matters by adding a new function, mingw_spawn_forkshell(),
which is tailored for just this case.
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | shell/ash.c | 2 | ||||
-rw-r--r-- | win32/process.c | 9 |
3 files changed, 11 insertions, 1 deletions
diff --git a/include/mingw.h b/include/mingw.h index 39d716521..26f0688d7 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -477,6 +477,7 @@ DIR *mingw_opendir(const char *path); | |||
477 | pid_t FAST_FUNC mingw_spawn(char **argv); | 477 | pid_t FAST_FUNC mingw_spawn(char **argv); |
478 | pid_t FAST_FUNC mingw_spawn_detach(char **argv); | 478 | pid_t FAST_FUNC mingw_spawn_detach(char **argv); |
479 | intptr_t FAST_FUNC mingw_spawn_proc(const char **argv); | 479 | intptr_t FAST_FUNC mingw_spawn_proc(const char **argv); |
480 | intptr_t FAST_FUNC mingw_spawn_forkshell(const char **argv); | ||
480 | int mingw_execv(const char *cmd, char *const *argv); | 481 | int mingw_execv(const char *cmd, char *const *argv); |
481 | int mingw_execvp(const char *cmd, char *const *argv); | 482 | int mingw_execvp(const char *cmd, char *const *argv); |
482 | int mingw_execve(const char *cmd, char *const *argv, char *const *envp); | 483 | int mingw_execve(const char *cmd, char *const *argv, char *const *envp); |
diff --git a/shell/ash.c b/shell/ash.c index 951e241ad..4a075d1ea 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -15627,7 +15627,7 @@ spawn_forkshell(struct forkshell *fs, struct job *jp, union node *n, int mode) | |||
15627 | new->nprocs = jp == NULL ? 0 : jp->nprocs; | 15627 | new->nprocs = jp == NULL ? 0 : jp->nprocs; |
15628 | sprintf(buf, "%p", new->hMapFile); | 15628 | sprintf(buf, "%p", new->hMapFile); |
15629 | argv[2] = buf; | 15629 | argv[2] = buf; |
15630 | ret = mingw_spawn_proc(argv); | 15630 | ret = mingw_spawn_forkshell(argv); |
15631 | CloseHandle(new->hMapFile); | 15631 | CloseHandle(new->hMapFile); |
15632 | UnmapViewOfFile(new); | 15632 | UnmapViewOfFile(new); |
15633 | if (ret == -1) { | 15633 | if (ret == -1) { |
diff --git a/win32/process.c b/win32/process.c index d33f06405..04775100b 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -391,6 +391,15 @@ mingw_spawn_proc(const char **argv) | |||
391 | return mingw_spawn_1(P_NOWAIT, argv[0], (char *const *)argv, environ); | 391 | return mingw_spawn_1(P_NOWAIT, argv[0], (char *const *)argv, environ); |
392 | } | 392 | } |
393 | 393 | ||
394 | #if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH | ||
395 | intptr_t FAST_FUNC | ||
396 | mingw_spawn_forkshell(const char **argv) | ||
397 | { | ||
398 | return spawnveq(P_NOWAIT, bb_busybox_exec_path, (char *const *)argv, | ||
399 | environ); | ||
400 | } | ||
401 | #endif | ||
402 | |||
394 | int | 403 | int |
395 | mingw_execvp(const char *cmd, char *const *argv) | 404 | mingw_execvp(const char *cmd, char *const *argv) |
396 | { | 405 | { |