GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — child_process: reduce abort handler code duplication · nodejs/node@b98cc51

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • child_process.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/child_process.js‎

Copy file name to clipboardExpand all lines: lib/child_process.js
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ function execFile(file /* , args, options, callback */) {
368368
}
369369
}
370370

371+
function abortHandler() {
372+
if (!ex)
373+
ex = new AbortError();
374+
process.nextTick(() => kill());
375+
}
376+
371377
if (options.timeout > 0) {
372378
timeoutId = setTimeout(function delayedKill() {
373379
kill();
@@ -376,16 +382,11 @@ function execFile(file /* , args, options, callback */) {
376382
}
377383
if (options.signal) {
378384
if (options.signal.aborted) {
379-
if (!ex)
380-
ex = new AbortError();
381-
process.nextTick(() => kill());
385+
process.nextTick(abortHandler);
382386
} else {
383387
const childController = new AbortController();
384-
options.signal.addEventListener('abort', () => {
385-
if (!ex)
386-
ex = new AbortError();
387-
kill();
388-
}, { signal: childController.signal });
388+
options.signal.addEventListener('abort', abortHandler,
389+
{ signal: childController.signal });
389390
child.once('close', () => childController.abort());
390391
}
391392
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.