mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-04 16:34:55 +01:00
fix: ensure shell cmds can be properly aborted (#2339)
This commit is contained in:
@@ -1141,6 +1141,7 @@ export namespace Session {
|
|||||||
const proc = spawn(shell, args, {
|
const proc = spawn(shell, args, {
|
||||||
cwd: app.path.cwd,
|
cwd: app.path.cwd,
|
||||||
signal: abort.signal,
|
signal: abort.signal,
|
||||||
|
detached: true,
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -1148,6 +1149,11 @@ export namespace Session {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
abort.signal.addEventListener("abort", () => {
|
||||||
|
if (!proc.pid) return
|
||||||
|
process.kill(-proc.pid)
|
||||||
|
})
|
||||||
|
|
||||||
let output = ""
|
let output = ""
|
||||||
|
|
||||||
proc.stdout?.on("data", (chunk) => {
|
proc.stdout?.on("data", (chunk) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user