本文介绍了从节点应用程序终止进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下代码来运行某些运行正常的进程,我的问题是是否有任何选项可以按需(通过代码)终止该进程

I've used the following code to run some process which is working OK,my question is if there any option to kill this process on demand (by code)

    var exec = require('child_process').exec;
    var cmd = 'any command';

    exec(cmd, function(error, stdout, stderr) {
....
    });


推荐答案

var child = exec(cmd, function(error, stdout, stderr) { ... });

// When you want to kill it:
child.kill(SIGNAL);

请参见。

这篇关于从节点应用程序终止进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:06
查看更多