Skip to content

Commit 96a0559

Browse files
committed
Handle killed commands better
1 parent 0091cc6 commit 96a0559

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tools/bash.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function bashTool(args: { command: string; timeout?: number }, cwd:
5656
reject(err);
5757
});
5858

59-
child.on("close", (code) => {
59+
child.on("close", (code, signal) => {
6060
if (timeoutHandle) clearTimeout(timeoutHandle);
6161

6262
const fullOutput = Buffer.concat(chunks).toString("utf-8");
@@ -78,7 +78,10 @@ export async function bashTool(args: { command: string; timeout?: number }, cwd:
7878
outputText += `\n\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(MAX_BYTES)} limit)]`;
7979
}
8080

81-
if (code !== 0 && code !== null) {
81+
if (signal) {
82+
outputText += `\n\nProcess was killed by ${signal}`;
83+
reject(new Error(outputText));
84+
} else if (code !== 0 && code !== null) {
8285
outputText += `\n\nCommand exited with code ${code}`;
8386
reject(new Error(outputText));
8487
} else {

0 commit comments

Comments
 (0)