mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
process: make execve's args argument optional
Align the code with the documentation and similar methods used to execute os commands - the `args` argument should be optional, and if omitted, treated as an empty array (`[]`). Fixes: https://github.com/nodejs/node/issues/58411 PR-URL: https://github.com/nodejs/node/pull/58412 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <richard.lau@ibm.com>
This commit is contained in:
parent
daa9e4bb8e
commit
a480d998d9
4 changed files with 36 additions and 1 deletions
|
@ -279,7 +279,7 @@ function wrapProcessMethods(binding) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function execve(execPath, args, env) {
|
function execve(execPath, args = [], env) {
|
||||||
emitExperimentalWarning('process.execve');
|
emitExperimentalWarning('process.execve');
|
||||||
|
|
||||||
const { isMainThread } = require('internal/worker');
|
const { isMainThread } = require('internal/worker');
|
||||||
|
|
7
node.gyp
7
node.gyp
|
@ -1338,6 +1338,13 @@
|
||||||
}],
|
}],
|
||||||
]
|
]
|
||||||
}, # overlapped-checker
|
}, # overlapped-checker
|
||||||
|
{
|
||||||
|
'target_name': 'nop',
|
||||||
|
'type': 'executable',
|
||||||
|
'sources': [
|
||||||
|
'test/nop/nop.c',
|
||||||
|
]
|
||||||
|
}, # nop
|
||||||
{
|
{
|
||||||
'target_name': 'node_js2c',
|
'target_name': 'node_js2c',
|
||||||
'type': 'executable',
|
'type': 'executable',
|
||||||
|
|
3
test/nop/nop.c
Normal file
3
test/nop/nop.c
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
int main(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
25
test/parallel/test-process-execve-no-args.js
Normal file
25
test/parallel/test-process-execve-no-args.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { skip, isWindows, isIBMi } = require('../common');
|
||||||
|
const { fail } = require('assert');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
const { dirname, join } = require('path');
|
||||||
|
const { existsSync } = require('fs');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
skip('process.execve is not available in Workers');
|
||||||
|
} else if (isWindows || isIBMi) {
|
||||||
|
skip('process.execve is not available in Windows or IBM i');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get full path to the executable used for the test
|
||||||
|
const executable = join(dirname(process.execPath), 'nop');
|
||||||
|
|
||||||
|
// Sanity check that the binary exists
|
||||||
|
if (!existsSync(executable)) {
|
||||||
|
skip(executable + ' binary is not available');
|
||||||
|
}
|
||||||
|
|
||||||
|
process.execve(executable);
|
||||||
|
// If process.execve succeeds, this should never be executed.
|
||||||
|
fail('process.execve failed');
|
Loading…
Add table
Add a link
Reference in a new issue