Skip to content

Commit 8fcc00f

Browse files
committed
backend/execute: document what is going on with the exit code handling and a kill signal
1 parent e59807e commit 8fcc00f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/packages/backend/execute-code.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ function doSpawn(
477477
finish();
478478
});
479479

480+
// Doc: https://nodejs.org/api/child_process.html#event-exit – read it!
481+
// TODO: This is not 100% correct, because in case the process is killed (signal TERM),
482+
// the $code is "null" and a second argument gives the signal (as a string). Hence, after a kill,
483+
// this code below changes the exit code to 0. This could be a special case, though.
484+
// It cannot be null, though, because the "finish" callback assumes that stdout, err and exit are set.
485+
// The local $killed var is only true, if the process has been killed by the timeout – not by another kill.
480486
child.on("exit", (code) => {
481487
exit_code = code ?? 0;
482488
finish();

0 commit comments

Comments
 (0)