Source SO
Reuiqures: node-ffi
// handle parent death
(function(){
var FFI = require('node-ffi'),
current = new FFI.Library(null, {"prctl": ["int32", ["int32", "uint32"]]}),
//1: PR_SET_PDEATHSIG, 15: SIGTERM
returned = current.prctl(1,15);
process.on('SIGTERM',function(){
//do something interesting
process.exit(1);
});
})();