diff options
author | Ron Yorston <rmy@pobox.com> | 2021-11-01 12:27:58 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-11-01 12:27:58 +0000 |
commit | 42a3e960faaff1458c7ca3c138d1847b1a104089 (patch) | |
tree | cad70d723a2fd743984d9a3255b01b2de90562e2 | |
parent | 0acd7c7984e680f2e352ed43556b2f4cc8da2fbb (diff) | |
download | busybox-w32-42a3e960faaff1458c7ca3c138d1847b1a104089.tar.gz busybox-w32-42a3e960faaff1458c7ca3c138d1847b1a104089.tar.bz2 busybox-w32-42a3e960faaff1458c7ca3c138d1847b1a104089.zip |
win32: UCRT environment hack
Commit 5b48ca53b (win32: pass NULL to spawnve, not environ) was an
attempt to fix a problem seen in busybox-w32 built against the UCRT
runtime. It was effective for applets like 'time' which pass an
unmodified environment to their children but not the shell which
needs to alter the environment to include exported shell variables.
A peculiar feature of the problem was that it only manifested when
the BusyBox binary was run by GNU make. Like the shell, make needs
to modify the environment passed to its children. GNU make therefore
creates a new environment block which is passed to CreateProcess.
As was the case with the previous commit passing a NULL pointer
instead made the problem go away.
It was also noted that failures only occurred when the child program
was built against UCRT. Whether make was linked against UCRT or
MVSCRT made no difference.
It appears that programs linked against UCRT are unable to handle
their parent passing a non-default environment block. It also
appears that setting an environment variable early in program
execution perturbs the environment block sufficiently to avoid
the problem. YMMV.
(GitHub issue #234)
-rw-r--r-- | libbb/appletlib.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 6c0be4a83..f0ed85215 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -1248,6 +1248,9 @@ 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 | ||
1251 | #endif | 1254 | #endif |
1252 | 1255 | ||
1253 | #if defined(__MINGW64_VERSION_MAJOR) | 1256 | #if defined(__MINGW64_VERSION_MAJOR) |