Skip to content

Commit

Permalink
lib: pass env variables to child process on z/OS
Browse files Browse the repository at this point in the history
PR-URL: #42255
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
alexcfyung authored and ruyadorno committed Aug 22, 2022
1 parent 05802c2 commit c02bbdd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const {

const MAX_BUFFER = 1024 * 1024;

const isZOS = process.platform === 'os390';

/**
* Spawns a new Node.js process + fork.
* @param {string|URL} modulePath
Expand Down Expand Up @@ -524,6 +526,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');

Expand Down Expand Up @@ -630,9 +640,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 = [];
Expand Down

0 comments on commit c02bbdd

Please sign in to comment.