Skip to content

Instantly share code, notes, and snippets.

@BigAB

BigAB/index.js Secret

Created June 9, 2017 04:16
Show Gist options
  • Save BigAB/703463f22c39cf19227dec2e72727bcf to your computer and use it in GitHub Desktop.
Save BigAB/703463f22c39cf19227dec2e72727bcf to your computer and use it in GitHub Desktop.
Infanticide Issue: child process lives after parent uncaught exception
const infanticide = require("infanticide");
const { exec } = require("child_process");
const child = exec(`sleep 5 && say "I am still going"`, {
cwd: process.cwd()
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
infanticide(child);
setTimeout(() => {
throw Error("...aaaaaaaaand Snap, parent error!");
}, 3000);
{
"name": "@bigab/infanticide-issue",
"version": "0.0.1",
"private": true,
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"dependencies": {
"infanticide": "^1.0.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment