summaryrefslogtreecommitdiff
path: root/packages/server/src
diff options
context:
space:
mode:
authorOlcan <[email protected]>2025-05-30 01:35:03 -0700
committerGitHub <[email protected]>2025-05-30 01:35:03 -0700
commita3b557222a95965de39920922df21439d69def57 (patch)
treeb2f5fd038a10f0ea659829658d2355c6bbe20941 /packages/server/src
parent094b9dc474fd8b99813acfa53e1192058314e9e4 (diff)
tweaks to shell abort logic based on feedback (#618)
Diffstat (limited to 'packages/server/src')
-rw-r--r--packages/server/src/tools/shell.ts17
1 files changed, 6 insertions, 11 deletions
diff --git a/packages/server/src/tools/shell.ts b/packages/server/src/tools/shell.ts
index a4634a3e..b43b2d0a 100644
--- a/packages/server/src/tools/shell.ts
+++ b/packages/server/src/tools/shell.ts
@@ -200,21 +200,16 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
};
shell.on('exit', exitHandler);
- const abortHandler = () => {
+ const abortHandler = async () => {
if (shell.pid && !exited) {
try {
// attempt to SIGTERM process group (negative PID)
- // if SIGTERM fails after 200ms, attempt SIGKILL
+ // fall back to SIGKILL (to group) after 200ms
process.kill(-shell.pid, 'SIGTERM');
- setTimeout(() => {
- try {
- if (shell.pid && !exited) {
- process.kill(-shell.pid, 'SIGKILL');
- }
- } catch (_e) {
- console.error(`failed to kill shell process ${shell.pid}: ${_e}`);
- }
- }, 200);
+ await new Promise((resolve) => setTimeout(resolve, 200));
+ if (shell.pid && !exited) {
+ process.kill(-shell.pid, 'SIGKILL');
+ }
} catch (_e) {
// if group kill fails, fall back to killing just the main process
try {