如何使用Node JS终止进程 [英] How to kill process with node js

查看:228
本文介绍了如何使用Node JS终止进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行使用IE,chrome和firefox驱动程序的BDD测试.有时,当我的测试失败时,它不会杀死驱动程序,因此它可以继续运行.我想用进程名称杀死所有进程,在Windows中是这样的

Im running BDD tests that uses IE, chrome and firefox drivers. Sometimes when my tests fails it doesnt kills the drivers so it keeps running. I want to kill all the process with the process name, something like this in windows

taskkill /F /IM chromedriver.exe /T

,但带有节点js或可在linux和Windows计算机中使用的东西.如果它带有一些gulp插件会很棒,那么我可以将其添加为任务.

but with node js or something that will work along in linux and windows machines. If its with some gulp plugin would be great so I can add it as a task.

推荐答案

您正在寻找类似 fkill之类的东西

可在macOS,Linux和Windows上运行.

Works on macOS, Linux, Windows.

用法示例:

const fkill = require('fkill');

fkill(1337).then(() => {
    console.log('Killed process');
});

fkill('Safari');

fkill([1337, 'Safari']);

这篇关于如何使用Node JS终止进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆