aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-11-04 12:27:45 +0000
committerRon Yorston <rmy@pobox.com>2021-11-04 12:27:45 +0000
commit9e12622a8706a0d23a3ff8792773e73b0d6108b4 (patch)
treefdbbfc2f59676cf9e3ce346f977adacb80711314
parent42a3e960faaff1458c7ca3c138d1847b1a104089 (diff)
downloadbusybox-w32-9e12622a8706a0d23a3ff8792773e73b0d6108b4.tar.gz
busybox-w32-9e12622a8706a0d23a3ff8792773e73b0d6108b4.tar.bz2
busybox-w32-9e12622a8706a0d23a3ff8792773e73b0d6108b4.zip
win32: move UCRT hack to process.c
Only apply the UCRT hack if we're about to call spawnve() with a non-NULL environment pointer. Add the pid of the process to the name of the environment variable to provide greater assurance that the environment will be changed.
-rw-r--r--libbb/appletlib.c3
-rw-r--r--win32/process.c8
2 files changed, 8 insertions, 3 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index f0ed85215..6c0be4a83 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -1248,9 +1248,6 @@ int main(int argc UNUSED_PARAM, char **argv)
1248 /* Ignore critical errors, such as calling GetVolumeInformation() on 1248 /* Ignore critical errors, such as calling GetVolumeInformation() on
1249 * a floppy or CDROM drive with no media. */ 1249 * a floppy or CDROM drive with no media. */
1250 SetErrorMode(SEM_FAILCRITICALERRORS); 1250 SetErrorMode(SEM_FAILCRITICALERRORS);
1251# ifdef _UCRT
1252 SetEnvironmentVariable("BB_HELLO", "world");
1253# endif
1254#endif 1251#endif
1255 1252
1256#if defined(__MINGW64_VERSION_MAJOR) 1253#if defined(__MINGW64_VERSION_MAJOR)
diff --git a/win32/process.c b/win32/process.c
index 812e259f4..137cb6a39 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -268,6 +268,14 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env)
268 new_path = xasprintf("%s.", path); 268 new_path = xasprintf("%s.", path);
269 } 269 }
270 270
271#if defined(_UCRT)
272 if (env) {
273 char buffer[64];
274
275 sprintf(buffer, "BB_HELLO_%d", getpid());
276 SetEnvironmentVariable(buffer, "1");
277 }
278#endif
271 errno = 0; 279 errno = 0;
272 ret = spawnve(mode, new_path ? new_path : path, new_argv, env); 280 ret = spawnve(mode, new_path ? new_path : path, new_argv, env);
273 281