Skip to content

Commit 8487184

Browse files
Nitzan Uzielydanielleadams
Nitzan Uziely
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 <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1ff375b commit 8487184

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/child_process.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,14 @@ function spawnWithSignal(file, args, options) {
758758
const opts = options && typeof options === 'object' && ('signal' in options) ?
759759
{ ...options, signal: undefined } :
760760
options;
761-
const child = spawn(file, args, opts);
762761

763-
if (options && options.signal) {
762+
if (options?.signal) {
764763
// Validate signal, if present
765764
validateAbortSignal(options.signal, 'options.signal');
765+
}
766+
const child = spawn(file, args, opts);
767+
768+
if (options && options.signal) {
766769
function kill() {
767770
if (child._handle) {
768771
child._handle.kill(options.killSignal || 'SIGTERM');

0 commit comments

Comments
 (0)