javascript - 用 JS 关闭 py 终端
问题描述
我想用 Javascript 关闭一个 py 终端,但我不知道如何杀死一个特定的进程
如果有人可以帮助我,那就太酷了
var kill = require('tree-kill');
const spawn = require('child_process').spawn;
var scriptArgs = ['myScript.sh', 'arg1', 'arg2', 'youGetThePoint'];
var child = spawn('sh', scriptArgs);
// some code to identify when you want to kill the process. Could be
// a button on the client-side??
button.on('someEvent', function(){
// where the killing happens
kill(child.pid);
});
我在 stackoverflow 上找到了这个,但我不太明白,文件名为“UP.py”,所以如果我不知道正确的 PID,我该如何关闭它
解决方案
推荐阅读
- android - 评估项目“:cloud_firestore”时出现问题
- javascript - 我的网站卡在预加载器循环中(CSS 损坏)
- saml - 在 Active Directory 联合服务上确定 SAML 版本的最简单方法是什么?
- r - 通过对分组变量的某些列求和来合并特定行
- pandas - GeoPandas:如何根据最近行的值填充系列的 NaN 值
- arrays - 预分配嵌套元胞数组matlab
- reactjs - 我有一个导航到主页的 deley 反应原生
- wordpress - 在 Elementor Form 小部件中翻译标准消息“请填写此字段”
- pyspark - 如果路径中有空格,如何从pyspark中的文件夹中递归读取文件
- xml - Pentaho Data Integration (Spoon) 使用嵌套元素导入 XML