Fix process termination issue in CommandRun class

This commit is contained in:
bobo.yang 2023-12-07 22:19:50 +08:00
parent 2548b8d8d3
commit d0efb81c62
3 changed files with 909 additions and 891 deletions

18
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "devchat",
"version": "0.1.55",
"version": "0.1.85",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "devchat",
"version": "0.1.55",
"version": "0.1.85",
"dependencies": {
"@emotion/react": "^11.10.8",
"@mantine/core": "^6.0.10",
@ -37,6 +37,7 @@
"rehype-raw": "^6.1.1",
"shell-escape": "^0.2.0",
"string-argv": "^0.3.2",
"tree-kill": "^1.2.2",
"unified": "^11.0.3",
"unist-util-visit": "^5.0.0",
"uuid": "^9.0.0",
@ -13768,6 +13769,14 @@
"node": "*"
}
},
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
"bin": {
"tree-kill": "cli.js"
}
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
@ -25100,6 +25109,11 @@
"integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==",
"dev": true
},
"tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="
},
"trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ import { logger } from './logger';
import { spawn, exec } from 'child_process';
import { UiUtilWrapper } from './uiUtil';
import { ApiKeyManager } from './apiKey';
var kill = require('tree-kill');
export async function saveModelSettings(): Promise<void> {
// support models
@ -196,8 +196,11 @@ export class CommandRun {
public stop() {
if (this.childProcess) {
this.childProcess.kill();
this.childProcess = null;
kill(this.childProcess.pid, 'SIGKILL', (err) => {
if (err) {
logger.channel()?.error('Failed to kill process tree:', err);
}
});
}
}
}