From b1a5034ca852efe2c24212db77d7b0b2660a687b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 12 Jun 2020 16:35:24 +0100 Subject: win32: minor improvements to process spawning The function mingw_spawn_forkshell() was introduced to handle spawning a forkshell process. Since we know that: - the binary being executed doesn't meet any of the special cases handled by spawnveq() - the arguments don't require quoting we can call spawnve() directly instead of spawnveq(). Also, use xzalloc() to allocate new_argv so we don't need to set the final NULL pointer explicitly. --- win32/process.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'win32') diff --git a/win32/process.c b/win32/process.c index 54628acad..f3d0a09f8 100644 --- a/win32/process.c +++ b/win32/process.c @@ -241,10 +241,9 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) } argc = string_array_len((char **)argv); - new_argv = xmalloc(sizeof(*argv)*(argc+1)); + new_argv = xzalloc(sizeof(*argv)*(argc+1)); for (i = 0;i < argc;i++) new_argv[i] = quote_arg(argv[i]); - new_argv[argc] = NULL; /* Special case: spawnve won't execute a batch file if the first * argument is a relative path containing forward slashes. Absolute @@ -395,7 +394,7 @@ mingw_spawn_proc(const char **argv) intptr_t FAST_FUNC mingw_spawn_forkshell(const char **argv) { - return spawnveq(P_NOWAIT, bb_busybox_exec_path, (char *const *)argv, + return spawnve(P_NOWAIT, bb_busybox_exec_path, (char *const *)argv, environ); } #endif -- cgit v1.2.3-55-g6feb