summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-10-15 15:20:14 -0500
committerAiden Cline <[email protected]>2025-10-15 15:20:14 -0500
commitd3caa55c108367e84da269f784406baf63474f38 (patch)
treec73934b722c5584e1b531691501b0fcbb5be216e
parentca534a36e590b4aba9f0feb00b9ee3362ce7ef0a (diff)
downloadopencode-d3caa55c108367e84da269f784406baf63474f38.tar.gz
opencode-d3caa55c108367e84da269f784406baf63474f38.zip
Revert "fix: spawns hanging (#3192)"
This reverts commit 278ffb9a4e7f99c7546ec8150b195d6e49476f3a.
-rw-r--r--packages/opencode/src/tool/bash.ts26
1 files changed, 7 insertions, 19 deletions
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts
index af1610d56..d4e8ce85a 100644
--- a/packages/opencode/src/tool/bash.ts
+++ b/packages/opencode/src/tool/bash.ts
@@ -145,26 +145,14 @@ export const BashTool = Tool.define("bash", {
})
}
- const proc = spawn(params.command, {
+ const process = spawn(params.command, {
shell: true,
cwd: Instance.directory,
signal: ctx.abort,
stdio: ["ignore", "pipe", "pipe"],
timeout,
- detached: process.platform !== "win32",
})
- if (!ctx.abort.aborted) {
- ctx.abort.addEventListener("abort", () => {
- if (!proc.pid) return
- if (process.platform === "win32") {
- proc.kill()
- return
- }
- process.kill(-proc.pid)
- })
- }
-
let output = ""
// Initialize metadata with empty output
@@ -175,7 +163,7 @@ export const BashTool = Tool.define("bash", {
},
})
- proc.stdout?.on("data", (chunk) => {
+ process.stdout?.on("data", (chunk) => {
output += chunk.toString()
ctx.metadata({
metadata: {
@@ -185,7 +173,7 @@ export const BashTool = Tool.define("bash", {
})
})
- proc.stderr?.on("data", (chunk) => {
+ process.stderr?.on("data", (chunk) => {
output += chunk.toString()
ctx.metadata({
metadata: {
@@ -196,7 +184,7 @@ export const BashTool = Tool.define("bash", {
})
await new Promise<void>((resolve) => {
- proc.on("close", () => {
+ process.on("close", () => {
resolve()
})
})
@@ -204,7 +192,7 @@ export const BashTool = Tool.define("bash", {
ctx.metadata({
metadata: {
output: output,
- exit: proc.exitCode,
+ exit: process.exitCode,
description: params.description,
},
})
@@ -214,7 +202,7 @@ export const BashTool = Tool.define("bash", {
output += "\n\n(Output was truncated due to length limit)"
}
- if (proc.signalCode === "SIGTERM" && params.timeout) {
+ if (process.signalCode === "SIGTERM" && params.timeout) {
output += `\n\n(Command timed out after ${timeout} ms)`
}
@@ -222,7 +210,7 @@ export const BashTool = Tool.define("bash", {
title: params.command,
metadata: {
output,
- exit: proc.exitCode,
+ exit: process.exitCode,
description: params.description,
},
output,