electron launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
437 B

  1. const { spawn } = require('child_process')
  2. let pidMap = {}
  3. function start(command, args) {
  4. const childProgress = spawn(command, args)
  5. pidMap[childProgress.pid] = childProgress
  6. return childProgress.pid
  7. }
  8. function kill(pid) {
  9. const childProgress = pidMap[pid]
  10. if (!childProgress || childProgress.killed) return;
  11. // TODO 需要测试是否能真正杀掉
  12. return childProgress.kill()
  13. }
  14. module.exports = {
  15. start,
  16. kill,
  17. }