Skip to content

Commit 8010c83

Browse files
Nitzan Uzielytargos
authored andcommitted
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: #37257 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9f6bc58 commit 8010c83

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/child_process.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,14 @@ function spawnWithSignal(file, args, options) {
870870
const opts = options && typeof options === 'object' && ('signal' in options) ?
871871
{ ...options, signal: undefined } :
872872
options;
873-
const child = spawn(file, args, opts);
874873

875-
if (options && options.signal) {
874+
if (options?.signal) {
876875
// Validate signal, if present
877876
validateAbortSignal(options.signal, 'options.signal');
877+
}
878+
const child = spawn(file, args, opts);
879+
880+
if (options && options.signal) {
878881
function kill() {
879882
if (child._handle) {
880883
child._handle.kill(options.killSignal || 'SIGTERM');

0 commit comments

Comments
 (0)