diff --git a/lib/child_process.js b/lib/child_process.js index 77b9ff35ff..364f908158 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -90,6 +90,8 @@ const { const MAX_BUFFER = 1024 * 1024; +const isZOS = process.platform === 'os390'; + /** * Spawns a new Node.js process + fork. * @param {string|URL} modulePath @@ -514,6 +516,14 @@ ObjectDefineProperty(execFile, promisify.custom, { value: customPromiseExecFunction(execFile) }); +function copyProcessEnvToEnv(env, name, optionEnv) { + if (process.env[name] && + (!optionEnv || + !ObjectPrototypeHasOwnProperty(optionEnv, name))) { + env[name] = process.env[name]; + } +} + function normalizeSpawnArguments(file, args, options) { validateString(file, 'file'); @@ -620,9 +630,19 @@ function normalizeSpawnArguments(file, args, options) { // process.env.NODE_V8_COVERAGE always propagates, making it possible to // collect coverage for programs that spawn with white-listed environment. - if (process.env.NODE_V8_COVERAGE && - !ObjectPrototypeHasOwnProperty(options.env || {}, 'NODE_V8_COVERAGE')) { - env.NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE; + copyProcessEnvToEnv(env, 'NODE_V8_COVERAGE', options.env); + + if (isZOS) { + // The following environment variables must always propagate if set. + copyProcessEnvToEnv(env, '_BPXK_AUTOCVT', options.env); + copyProcessEnvToEnv(env, '_CEE_RUNOPTS', options.env); + copyProcessEnvToEnv(env, '_TAG_REDIR_ERR', options.env); + copyProcessEnvToEnv(env, '_TAG_REDIR_IN', options.env); + copyProcessEnvToEnv(env, '_TAG_REDIR_OUT', options.env); + copyProcessEnvToEnv(env, 'STEPLIB', options.env); + copyProcessEnvToEnv(env, 'LIBPATH', options.env); + copyProcessEnvToEnv(env, '_EDC_SIG_DFLT', options.env); + copyProcessEnvToEnv(env, '_EDC_SUSV3', options.env); } let envKeys = [];