aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-10-28 14:24:24 +0100
committerRon Yorston <rmy@pobox.com>2021-10-28 14:24:24 +0100
commit5b48ca53be57bc907ed8dd00635914556b4472e4 (patch)
tree98b7ad2143efaa39608227eb470b8903e19d9b3d /win32
parentd239d2d5273e1620a6146d8f5076f6532e3569b1 (diff)
downloadbusybox-w32-5b48ca53be57bc907ed8dd00635914556b4472e4.tar.gz
busybox-w32-5b48ca53be57bc907ed8dd00635914556b4472e4.tar.bz2
busybox-w32-5b48ca53be57bc907ed8dd00635914556b4472e4.zip
win32: pass NULL to spawnve, not environ
Building busybox-w32 for use with UCRT results in mysterious failures. (GitHub issue #234) These are somehow related to the environment values passed to spawnve. In several places the global environ pointer was being passed to spawnve so the child would inherit its environment from the parent. This can also be achieved by passing a NULL pointer. This prevents the failures in at least some cases and also makes the binary smaller.
Diffstat (limited to 'win32')
-rw-r--r--win32/process.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/win32/process.c b/win32/process.c
index 1b344f747..d5f386a1b 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -378,7 +378,7 @@ mingw_spawn_pid(int mode, char **argv)
378{ 378{
379 intptr_t ret; 379 intptr_t ret;
380 380
381 ret = mingw_spawn_1(mode, argv[0], (char *const *)argv, environ); 381 ret = mingw_spawn_1(mode, argv[0], (char *const *)argv, NULL);
382 382
383 return ret == -1 ? (pid_t)-1 : (pid_t)GetProcessId((HANDLE)ret); 383 return ret == -1 ? (pid_t)-1 : (pid_t)GetProcessId((HANDLE)ret);
384} 384}
@@ -398,13 +398,13 @@ mingw_spawn_detach(char **argv)
398intptr_t FAST_FUNC 398intptr_t FAST_FUNC
399mingw_spawn_proc(const char **argv) 399mingw_spawn_proc(const char **argv)
400{ 400{
401 return mingw_spawn_1(P_NOWAIT, argv[0], (char *const *)argv, environ); 401 return mingw_spawn_1(P_NOWAIT, argv[0], (char *const *)argv, NULL);
402} 402}
403 403
404int 404int
405mingw_execvp(const char *cmd, char *const *argv) 405mingw_execvp(const char *cmd, char *const *argv)
406{ 406{
407 int ret = (int)mingw_spawn_1(P_WAIT, cmd, argv, environ); 407 int ret = (int)mingw_spawn_1(P_WAIT, cmd, argv, NULL);
408 if (ret != -1 || errno == 0) 408 if (ret != -1 || errno == 0)
409 exit(ret); 409 exit(ret);
410 return ret; 410 return ret;
@@ -422,7 +422,7 @@ mingw_execve(const char *cmd, char *const *argv, char *const *envp)
422int 422int
423mingw_execv(const char *cmd, char *const *argv) 423mingw_execv(const char *cmd, char *const *argv)
424{ 424{
425 return mingw_execve(cmd, argv, environ); 425 return mingw_execve(cmd, argv, NULL);
426} 426}
427 427
428static inline long long filetime_to_ticks(const FILETIME *ft) 428static inline long long filetime_to_ticks(const FILETIME *ft)