MCPcopy Index your code
hub / github.com/nodejs/node / exithandler

Function exithandler

lib/child_process.js:378–425  ·  view source on GitHub ↗
(code, signal)

Source from the content-addressed store, hash-verified

376 let cmd = file;
377
378 function exithandler(code, signal) {
379 if (exited) return;
380 exited = true;
381
382 if (timeoutId) {
383 clearTimeout(timeoutId);
384 timeoutId = null;
385 }
386
387 if (!callback) return;
388
389 // merge chunks
390 let stdout;
391 let stderr;
392 if (encoding ||
393 (
394 child.stdout?.readableEncoding
395 )) {
396 stdout = ArrayPrototypeJoin(_stdout, '');
397 } else {
398 stdout = Buffer.concat(_stdout);
399 }
400 if (encoding ||
401 (
402 child.stderr?.readableEncoding
403 )) {
404 stderr = ArrayPrototypeJoin(_stderr, '');
405 } else {
406 stderr = Buffer.concat(_stderr);
407 }
408
409 if (!ex && code === 0 && signal === null) {
410 callback(null, stdout, stderr);
411 return;
412 }
413
414 if (args?.length)
415 cmd += ` ${ArrayPrototypeJoin(args, ' ')}`;
416
417 ex ||= genericNodeError(`Command failed: ${cmd}\n${stderr}`, {
418 code: code < 0 ? getSystemErrorName(code) : code,
419 killed: child.killed || killed,
420 signal: signal,
421 });
422
423 ex.cmd = cmd;
424 callback(ex, stdout, stderr);
425 }
426
427 function errorhandler(e) {
428 ex = e;

Callers 2

errorhandlerFunction · 0.85
killFunction · 0.85

Calls 4

concatMethod · 0.80
clearTimeoutFunction · 0.70
getSystemErrorNameFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…