respawn.js 409 B

12345678910111213141516
  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. /* istanbul ignore if */
  7. if (signal) {
  8. process.kill(process.pid, signal);
  9. } else {
  10. process.exit(code);
  11. }
  12. });
  13. });
  14. return child;
  15. };