Skip to content

Commit

Permalink
child_process: fix bad abort signal leak
Browse files Browse the repository at this point in the history
Move abort signal validation to before spawn is executed
so that the file is not leaked.
  • Loading branch information
Nitzan Uziely committed Feb 6, 2021
1 parent d6e9446 commit f77f233
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/child_process.js
Expand Up @@ -758,11 +758,14 @@ function spawnWithSignal(file, args, options) {
const opts = options && typeof options === 'object' && ('signal' in options) ?
{ ...options, signal: undefined } :
options;
const child = spawn(file, args, opts);

if (options && options.signal) {
if(options?.signal) {
// Validate signal, if present
validateAbortSignal(options.signal, 'options.signal');
}
const child = spawn(file, args, opts);

if (options && options.signal) {
function kill() {
if (child._handle) {
child._handle.kill(options.killSignal || 'SIGTERM');
Expand Down

0 comments on commit f77f233

Please sign in to comment.