From b29a9e012c55ab028c1e2c8e5febe486b1f2a8ee Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 29 Apr 2023 22:49:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=81=9C=E6=AD=A2=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 10 +++++++--- shell/task.sh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index a0ed8161..d943bdbe 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -469,11 +469,15 @@ export function psTree(pid: number): Promise { export async function killTask(pid: number) { const pids = await psTree(pid); - // SIGALRM 14 时钟信号 + // SIGINT 2 程序终止(interrupt)信号,不会打印额外信息 if (pids.length) { - process.kill(pids[0], 14); + try { + [pid, ...pids].forEach((x) => { + process.kill(x, 2); + }); + } catch (error) {} } else { - process.kill(pid, 14); + process.kill(pid, 2); } } diff --git a/shell/task.sh b/shell/task.sh index a2703f70..de4e7f4d 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -74,7 +74,7 @@ format_params() { fi timeoutCmd="" if type timeout &>/dev/null; then - timeoutCmd="timeout --foreground -s 14 -k 10s $command_timeout_time " + timeoutCmd="timeout --foreground -s 2 -k 10s $command_timeout_time " fi # params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g') }