aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-04-24 09:08:51 +0100
committerRon Yorston <rmy@pobox.com>2022-04-24 09:08:51 +0100
commitbd43e03eaaf685aec32dbb8997d6d27679215d2b (patch)
treec82131c5129247bedce71cc1594efce51d697ca0
parent2f0c3703f803e3011d8f0fdd618c796ada7b2925 (diff)
downloadbusybox-w32-bd43e03eaaf685aec32dbb8997d6d27679215d2b.tar.gz
busybox-w32-bd43e03eaaf685aec32dbb8997d6d27679215d2b.tar.bz2
busybox-w32-bd43e03eaaf685aec32dbb8997d6d27679215d2b.zip
win32: conditional compilation in process.c
Drop the use of ENABLE_FEATURE_SH_STANDALONE in process.c In mingw_spawn_interpreter() check for an applet *before* trying to run the interpreter using the path provided.
-rw-r--r--win32/process.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/win32/process.c b/win32/process.c
index fb3c5b369..d4ab07ad8 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -2,6 +2,7 @@
2#include <tlhelp32.h> 2#include <tlhelp32.h>
3#include <psapi.h> 3#include <psapi.h>
4#include "lazyload.h" 4#include "lazyload.h"
5#include "NUM_APPLETS.h"
5 6
6pid_t waitpid(pid_t pid, int *status, int options) 7pid_t waitpid(pid_t pid, int *status, int options)
7#if ENABLE_TIME 8#if ENABLE_TIME
@@ -282,7 +283,7 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env)
282 return ret; 283 return ret;
283} 284}
284 285
285#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE 286#if ENABLE_FEATURE_PREFER_APPLETS && NUM_APPLETS > 1
286static intptr_t 287static intptr_t
287mingw_spawn_applet(int mode, 288mingw_spawn_applet(int mode,
288 char *const *argv, 289 char *const *argv,
@@ -318,19 +319,18 @@ mingw_spawn_interpreter(int mode, const char *prog, char *const *argv,
318 new_argv[nopts+1] = (char *)prog; /* pass absolute path */ 319 new_argv[nopts+1] = (char *)prog; /* pass absolute path */
319 memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc); 320 memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc);
320 321
321 fullpath = alloc_system_drive(interp.path); 322#if ENABLE_FEATURE_PREFER_APPLETS && NUM_APPLETS > 1
322 if (add_win32_extension(fullpath) || file_is_executable(fullpath)) {
323 new_argv[0] = fullpath;
324 ret = mingw_spawn_interpreter(mode, new_argv[0], new_argv, envp, level);
325 } else
326#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE
327 if (find_applet_by_name(interp.name) >= 0) { 323 if (find_applet_by_name(interp.name) >= 0) {
328 /* the fake path indicates the index of the script */ 324 /* the fake path indicates the index of the script */
329 new_argv[0] = fullpath = xasprintf("%d:/%s", nopts+1, interp.name); 325 new_argv[0] = fullpath = xasprintf("%d:/%s", nopts+1, interp.name);
330 ret = mingw_spawn_applet(mode, new_argv, envp); 326 ret = mingw_spawn_applet(mode, new_argv, envp);
331 } else 327 } else
332#endif 328#endif
333 { 329 if ((fullpath = alloc_system_drive(interp.path)) &&
330 (add_win32_extension(fullpath) || file_is_executable(fullpath))) {
331 new_argv[0] = fullpath;
332 ret = mingw_spawn_interpreter(mode, new_argv[0], new_argv, envp, level);
333 } else {
334 errno = ENOENT; 334 errno = ENOENT;
335 ret = -1; 335 ret = -1;
336 } 336 }
@@ -346,7 +346,7 @@ mingw_spawnvp(int mode, const char *cmd, char *const *argv)
346 char *prog; 346 char *prog;
347 intptr_t ret; 347 intptr_t ret;
348 348
349#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE 349#if ENABLE_FEATURE_PREFER_APPLETS && NUM_APPLETS > 1
350 if (find_applet_by_name(cmd) >= 0) 350 if (find_applet_by_name(cmd) >= 0)
351 return mingw_spawn_applet(mode, argv, NULL); 351 return mingw_spawn_applet(mode, argv, NULL);
352 else 352 else
@@ -356,7 +356,7 @@ mingw_spawnvp(int mode, const char *cmd, char *const *argv)
356 add_win32_extension(path); 356 add_win32_extension(path);
357 ret = mingw_spawn_interpreter(mode, path, argv, NULL, 0); 357 ret = mingw_spawn_interpreter(mode, path, argv, NULL, 0);
358 free(path); 358 free(path);
359#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE 359#if ENABLE_FEATURE_PREFER_APPLETS && NUM_APPLETS > 1
360 if (ret == -1 && unix_path(cmd) && 360 if (ret == -1 && unix_path(cmd) &&
361 find_applet_by_name(bb_basename(cmd)) >= 0) { 361 find_applet_by_name(bb_basename(cmd)) >= 0) {
362 return mingw_spawn_applet(mode, argv, NULL); 362 return mingw_spawn_applet(mode, argv, NULL);