|
| 1 | +diff --git a/dist/NodeChildProcessSpawner.js b/dist/NodeChildProcessSpawner.js |
| 2 | +--- a/dist/NodeChildProcessSpawner.js |
| 3 | ++++ b/dist/NodeChildProcessSpawner.js |
| 4 | +@@ -44,9 +44,17 @@ |
| 5 | + return false; |
| 6 | + } |
| 7 | + }; |
| 8 | +-const taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { |
| 9 | +- windowsHide: true |
| 10 | +-}, onExit); |
| 11 | ++const taskkill = (childProcess, onExit = () => {}) => { |
| 12 | ++ // Once Node observes the leader's exit, taskkill /T cannot reclaim orphaned |
| 13 | ++ // descendants through its PID, which may be reused. Skip stale-PID cleanup. |
| 14 | ++ if (childProcess.exitCode !== null || childProcess.signalCode !== null) { |
| 15 | ++ onExit(null); |
| 16 | ++ return; |
| 17 | ++ } |
| 18 | ++ NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { |
| 19 | ++ windowsHide: true |
| 20 | ++ }, onExit); |
| 21 | ++}; |
| 22 | + const make = /*#__PURE__*/Effect.gen(function* () { |
| 23 | + const fs = yield* FileSystem.FileSystem; |
| 24 | + const path = yield* Path.Path; |
| 25 | +diff --git a/src/NodeChildProcessSpawner.ts b/src/NodeChildProcessSpawner.ts |
| 26 | +--- a/src/NodeChildProcessSpawner.ts |
| 27 | ++++ b/src/NodeChildProcessSpawner.ts |
| 28 | +@@ -19,7 +19,9 @@ |
| 29 | + * `forceKillAfter`, the wait is limited to one second and never escalates. |
| 30 | + * With it, cleanup may take the configured duration plus a final one-second |
| 31 | + * wait after `SIGKILL`. Zombie descendants can consume either full bound. On |
| 32 | +- * Windows, `taskkill` terminates the tree and only the leader's exit is awaited. |
| 33 | ++ * Windows, `taskkill` terminates the tree while the leader is running and only |
| 34 | ++ * the leader's exit is awaited. Descendants that outlive the leader are not |
| 35 | ++ * reclaimed by PID-based cleanup. |
| 36 | + * |
| 37 | + * POSIX cleanup targets a numeric process-group ID. If the group disappears |
| 38 | + * and its ID is reused before cleanup, an unrelated group may be signalled. |
| 39 | +@@ -99,13 +101,20 @@ |
| 40 | + const taskkill = ( |
| 41 | + childProcess: NodeChildProcess.ChildProcess, |
| 42 | + onExit: (error: NodeChildProcess.ExecException | null) => void = () => {} |
| 43 | +-) => |
| 44 | ++) => { |
| 45 | ++ // Once Node observes the leader's exit, taskkill /T cannot reclaim orphaned |
| 46 | ++ // descendants through its PID, which may be reused. Skip stale-PID cleanup. |
| 47 | ++ if (childProcess.exitCode !== null || childProcess.signalCode !== null) { |
| 48 | ++ onExit(null) |
| 49 | ++ return |
| 50 | ++ } |
| 51 | + NodeChildProcess.execFile( |
| 52 | + "taskkill", |
| 53 | + ["/pid", String(childProcess.pid!), "/T", "/F"], |
| 54 | + { windowsHide: true }, |
| 55 | + onExit |
| 56 | + ) |
| 57 | ++} |
| 58 | + |
| 59 | + const make = Effect.gen(function*() { |
| 60 | + const fs = yield* FileSystem.FileSystem |
0 commit comments