From c8ffb7d64be02c2a1b8effbd233d5e30ebb19474 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Mon, 14 Apr 2025 13:59:43 -0500 Subject: [PATCH 1/2] process: disable building execve on IBM i The `execve` syscall does exist on IBM i but it has caveats that make it not usable in Node.js context. These changes disable building with `execve` like Windows does. --- doc/api/process.md | 2 +- src/node_process_methods.cc | 6 +++--- test/parallel/test-process-execve-abort.js | 6 +++--- test/parallel/test-process-execve-on-exit.js | 6 +++--- test/parallel/test-process-execve-permission-fail.js | 6 +++--- test/parallel/test-process-execve-permission-granted.js | 6 +++--- test/parallel/test-process-execve-socket.js | 6 +++--- test/parallel/test-process-execve-validation.js | 4 ++-- test/parallel/test-process-execve-worker-threads.js | 6 +++--- test/parallel/test-process-execve.js | 6 +++--- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 2ba2794cffec94..8fb0e38834b32c 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -3379,7 +3379,7 @@ any exit or close events and without running any cleanup handler. This function will never return, unless an error occurred. -This function is not available on Windows. +This function is not available on Windows or IBM i. ## `process.report` diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 3866c612600642..ac51780f1535a3 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -497,7 +497,7 @@ static void ReallyExit(const FunctionCallbackInfo& args) { env->Exit(code); } -#ifdef __POSIX__ +#if defined __POSIX__ && !defined(__PASE__) inline int persist_standard_stream(int fd) { int flags = fcntl(fd, F_GETFD, 0); @@ -779,7 +779,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data, SetMethod(isolate, target, "dlopen", binding::DLOpen); SetMethod(isolate, target, "reallyExit", ReallyExit); -#ifdef __POSIX__ +#if defined __POSIX__ && !defined(__PASE__) SetMethod(isolate, target, "execve", Execve); #endif SetMethodNoSideEffect(isolate, target, "uptime", Uptime); @@ -826,7 +826,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) { registry->Register(binding::DLOpen); registry->Register(ReallyExit); -#ifdef __POSIX__ +#if defined __POSIX__ && !defined(__PASE__) registry->Register(Execve); #endif registry->Register(Uptime); diff --git a/test/parallel/test-process-execve-abort.js b/test/parallel/test-process-execve-abort.js index 515e1c1f8f5240..4a36944ac83ab0 100644 --- a/test/parallel/test-process-execve-abort.js +++ b/test/parallel/test-process-execve-abort.js @@ -1,14 +1,14 @@ 'use strict'; -const { skip, isWindows } = require('../common'); +const { skip, isWindows, isIBMi } = require('../common'); const { ok } = require('assert'); const { spawnSync } = require('child_process'); const { isMainThread } = require('worker_threads'); if (!isMainThread) { skip('process.execve is not available in Workers'); -} else if (isWindows) { - skip('process.execve is not available in Windows'); +} else if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (process.argv[2] === 'child') { diff --git a/test/parallel/test-process-execve-on-exit.js b/test/parallel/test-process-execve-on-exit.js index e6859b51fe27ce..ff01b0b50e2581 100644 --- a/test/parallel/test-process-execve-on-exit.js +++ b/test/parallel/test-process-execve-on-exit.js @@ -1,13 +1,13 @@ 'use strict'; -const { mustNotCall, skip, isWindows } = require('../common'); +const { mustNotCall, skip, isWindows, isIBMi } = require('../common'); const { strictEqual } = require('assert'); const { isMainThread } = require('worker_threads'); if (!isMainThread) { skip('process.execve is not available in Workers'); -} else if (isWindows) { - skip('process.execve is not available in Windows'); +} else if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (process.argv[2] === 'replaced') { diff --git a/test/parallel/test-process-execve-permission-fail.js b/test/parallel/test-process-execve-permission-fail.js index 0398552edd577e..f1fceca2700245 100644 --- a/test/parallel/test-process-execve-permission-fail.js +++ b/test/parallel/test-process-execve-permission-fail.js @@ -2,14 +2,14 @@ 'use strict'; -const { mustCall, skip, isWindows } = require('../common'); +const { mustCall, skip, isWindows, isIBMi } = require('../common'); const { fail, throws } = require('assert'); const { isMainThread } = require('worker_threads'); if (!isMainThread) { skip('process.execve is not available in Workers'); -} else if (isWindows) { - skip('process.execve is not available in Windows'); +} else if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (process.argv[2] === 'replaced') { diff --git a/test/parallel/test-process-execve-permission-granted.js b/test/parallel/test-process-execve-permission-granted.js index 3521b240f00ab7..f4d36d83f07a29 100644 --- a/test/parallel/test-process-execve-permission-granted.js +++ b/test/parallel/test-process-execve-permission-granted.js @@ -2,14 +2,14 @@ 'use strict'; -const { skip, isWindows } = require('../common'); +const { skip, isWindows, isIBMi } = require('../common'); const { deepStrictEqual } = require('assert'); const { isMainThread } = require('worker_threads'); if (!isMainThread) { skip('process.execve is not available in Workers'); -} else if (isWindows) { - skip('process.execve is not available in Windows'); +} else if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (process.argv[2] === 'replaced') { diff --git a/test/parallel/test-process-execve-socket.js b/test/parallel/test-process-execve-socket.js index 9d85f7ce2bf938..d113f690a09ab9 100644 --- a/test/parallel/test-process-execve-socket.js +++ b/test/parallel/test-process-execve-socket.js @@ -1,14 +1,14 @@ 'use strict'; -const { mustCall, mustNotCall, skip, isWindows } = require('../common'); +const { mustCall, mustNotCall, skip, isWindows, isIBMi } = require('../common'); const { fail, ok } = require('assert'); const { createServer } = require('net'); const { isMainThread } = require('worker_threads'); if (!isMainThread) { skip('process.execve is not available in Workers'); -} else if (isWindows) { - skip('process.execve is not available in Windows'); +} else if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (process.argv[2] === 'replaced') { diff --git a/test/parallel/test-process-execve-validation.js b/test/parallel/test-process-execve-validation.js index 339d53d5737d64..febaa12d06c30f 100644 --- a/test/parallel/test-process-execve-validation.js +++ b/test/parallel/test-process-execve-validation.js @@ -1,6 +1,6 @@ 'use strict'; -const { skip, isWindows } = require('../common'); +const { skip, isWindows, isIBMi } = require('../common'); const { throws } = require('assert'); const { isMainThread } = require('worker_threads'); @@ -8,7 +8,7 @@ if (!isMainThread) { skip('process.execve is not available in Workers'); } -if (!isWindows) { +if (!isWindows && !isIBMi) { // Invalid path name { throws(() => { diff --git a/test/parallel/test-process-execve-worker-threads.js b/test/parallel/test-process-execve-worker-threads.js index 5b93f45bbeb930..551f6f7ac30691 100644 --- a/test/parallel/test-process-execve-worker-threads.js +++ b/test/parallel/test-process-execve-worker-threads.js @@ -1,11 +1,11 @@ 'use strict'; -const { isWindows, mustCall, skip } = require('../common'); +const { isWindows, isIBMi, mustCall, skip } = require('../common'); const { throws } = require('assert'); const { isMainThread, Worker } = require('worker_threads'); -if (isWindows) { - skip('process.execve is not available in Windows'); +if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (isMainThread) { diff --git a/test/parallel/test-process-execve.js b/test/parallel/test-process-execve.js index 1cc9bf87018497..b0d4bc05158f62 100644 --- a/test/parallel/test-process-execve.js +++ b/test/parallel/test-process-execve.js @@ -1,13 +1,13 @@ 'use strict'; -const { isWindows, skip } = require('../common'); +const { isWindows, isIBMi, skip } = require('../common'); const { deepStrictEqual, fail, strictEqual } = require('assert'); const { isMainThread } = require('worker_threads'); if (!isMainThread) { skip('process.execve is not available in Workers'); -} else if (isWindows) { - skip('process.execve is not available in Windows'); +} else if (isWindows || isIBMi) { + skip('process.execve is not available in Windows or IBM i'); } if (process.argv[2] === 'replaced') { From ed3865cb275ff1017179116fa785939f4e5da5aa Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Tue, 15 Apr 2025 14:20:46 -0500 Subject: [PATCH 2/2] fixup! process: disable building execve on IBM i --- lib/internal/process/per_thread.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 335b8868304bf4..36ac1046dab471 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -286,7 +286,7 @@ function wrapProcessMethods(binding) { if (!isMainThread) { throw new ERR_WORKER_UNSUPPORTED_OPERATION('Calling process.execve'); - } else if (process.platform === 'win32') { + } else if (process.platform === 'win32' || process.platform === 'os400') { throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM('process.execve'); }