How to kill childprocess in nodejs?

后端 未结 1 362
[愿得一人]
[愿得一人] 2020-11-30 07:20

Created a childprocess using shelljs

!/usr/bin/env node

require(\'/usr/local/lib/node_modules/shelljs/global\');
   fs = require(\"fs\");  
   var child=exe         


        
相关标签:
1条回答
  • 2020-11-30 07:47

    If you can use node's built in child_process.spawn, you're able to send a SIGINT signal to the child process:

    var proc = require('child_process').spawn('mongod');
    proc.kill('SIGINT');
    

    An upside to this is that the main process should hang around until all of the child processes have terminated.

    0 讨论(0)
提交回复
热议问题