respawn.js 378 B

123456789101112131415
  1. const spawn = require('child_process').spawn;
  2. module.exports = function (argv) {
  3. var child = spawn(argv[0], argv.slice(1), { stdio: 'inherit' });
  4. child.on('exit', function (code, signal) {
  5. process.on('exit', function () {
  6. if (signal) {
  7. process.kill(process.pid, signal);
  8. } else {
  9. process.exit(code);
  10. }
  11. });
  12. });
  13. return child;
  14. };