| 214 | return { ok: true } |
| 215 | }, |
| 216 | async killAll() { |
| 217 | for (const [id, state] of local.active) { |
| 218 | if (state.timeout) clearTimeout(state.timeout) |
| 219 | if (state.cleanup) clearTimeout(state.cleanup) |
| 220 | |
| 221 | if (!state.completed) { |
| 222 | state.completed = true |
| 223 | state.exitCode = null |
| 224 | state.signal = "SIGKILL" |
| 225 | try { |
| 226 | if (process.platform !== "win32" && state.process.pid) process.kill(-state.process.pid, "SIGKILL") |
| 227 | else state.process.kill("SIGKILL") |
| 228 | } catch { |
| 229 | try { |
| 230 | state.process.kill("SIGKILL") |
| 231 | } catch { |
| 232 | // The process may already be gone; the runtime still needs a terminal lifecycle event. |
| 233 | } |
| 234 | } |
| 235 | emit(local, { type: "exit", processId: id, exitCode: null, signal: "SIGKILL" }) |
| 236 | } |
| 237 | |
| 238 | if (state.tempScriptPath) await fs.rm(state.tempScriptPath, { force: true }).catch(() => undefined) |
| 239 | local.active.delete(id) |
| 240 | } |
| 241 | return { ok: true } |
| 242 | }, |
| 243 | } |
| 244 | } |