mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
child_process: fix bad abort signal leak
Move abort signal validation to before spawn is executed so that the file is not leaked. PR-URL: https://github.com/nodejs/node/pull/37257 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
9f6bc58da8
commit
8010c83180
1 file changed
+5
-2
@@ -870,11 +870,14 @@ function spawnWithSignal(file, args, options) {
|
||||
const opts = options && typeof options === 'object' && ('signal' in options) ?
|
||||
{ ...options, signal: undefined } :
|
||||
options;
|
||||
|
||||
if (options?.signal) {
|
||||
// Validate signal, if present
|
||||
validateAbortSignal(options.signal, 'options.signal');
|
||||
}
|
||||
const child = spawn(file, args, opts);
|
||||
|
||||
if (options && options.signal) {
|
||||
// Validate signal, if present
|
||||
validateAbortSignal(options.signal, 'options.signal');
|
||||
function kill() {
|
||||
if (child._handle) {
|
||||
child._handle.kill(options.killSignal || 'SIGTERM');
|
||||
|
||||
Reference in new issue
Block a user