Skip to content

Commit

Permalink
Merge pull request #3 from ChaosLabsInc/kill-process-new
Browse files Browse the repository at this point in the history
Kill process on exit
  • Loading branch information
ronlv10 committed Jul 27, 2023
2 parents 7706a08 + b08631b commit 6814a43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/classes/main-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default (
await childProcessor.start(msg.job);
break;
case ChildCommand.Stop:
break;
process.exit(0);
}
} catch (err) {
console.error('Error handling child message');
Expand Down
8 changes: 3 additions & 5 deletions src/classes/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ const sandbox = <T, R, N extends string>(
child.off('message', msgHandler);
child.off('exit', exitHandler);

if (child.exitCode !== null || /SIG.*/.test(`${child.signalCode}`)) {
childPool.remove(child);
} else {
childPool.release(child);
}
await childPool.kill(child).catch(err => {
console.error(err);
});
}
};
};
Expand Down

0 comments on commit 6814a43

Please sign in to comment.