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.

PR-URL: #37257
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Nitzan Uziely authored and benjamingr committed Feb 12, 2021
1 parent 5bf2737 commit 2272713
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
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 2272713

Please sign in to comment.