/usr/lib/nodejs/exit-hook/index.js is in node-exit-hook 1.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 'use strict';
var cbs = [];
var called = false;
function exit(exit, signal) {
if (called) {
return;
}
called = true;
cbs.forEach(function (el) {
el();
});
if (exit === true) {
process.exit(128 + signal);
}
};
module.exports = function (cb) {
cbs.push(cb);
if (cbs.length === 1) {
process.once('exit', exit);
process.once('SIGINT', exit.bind(null, true, 2));
process.once('SIGTERM', exit.bind(null, true, 15));
}
};
|