Files
t3code/patches/@[email protected]
T

61 lines
2.4 KiB
Diff

diff --git a/dist/NodeChildProcessSpawner.js b/dist/NodeChildProcessSpawner.js
--- a/dist/NodeChildProcessSpawner.js
+++ b/dist/NodeChildProcessSpawner.js
@@ -44,9 +44,17 @@
return false;
}
};
-const taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
- windowsHide: true
-}, onExit);
+const taskkill = (childProcess, onExit = () => {}) => {
+ // Once Node observes the leader's exit, taskkill /T cannot reclaim orphaned
+ // descendants through its PID, which may be reused. Skip stale-PID cleanup.
+ if (childProcess.exitCode !== null || childProcess.signalCode !== null) {
+ onExit(null);
+ return;
+ }
+ NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
+ windowsHide: true
+ }, onExit);
+};
const make = /*#__PURE__*/Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
diff --git a/src/NodeChildProcessSpawner.ts b/src/NodeChildProcessSpawner.ts
--- a/src/NodeChildProcessSpawner.ts
+++ b/src/NodeChildProcessSpawner.ts
@@ -19,7 +19,9 @@
* `forceKillAfter`, the wait is limited to one second and never escalates.
* With it, cleanup may take the configured duration plus a final one-second
* wait after `SIGKILL`. Zombie descendants can consume either full bound. On
- * Windows, `taskkill` terminates the tree and only the leader's exit is awaited.
+ * Windows, `taskkill` terminates the tree while the leader is running and only
+ * the leader's exit is awaited. Descendants that outlive the leader are not
+ * reclaimed by PID-based cleanup.
*
* POSIX cleanup targets a numeric process-group ID. If the group disappears
* and its ID is reused before cleanup, an unrelated group may be signalled.
@@ -99,13 +101,20 @@
const taskkill = (
childProcess: NodeChildProcess.ChildProcess,
onExit: (error: NodeChildProcess.ExecException | null) => void = () => {}
-) =>
+) => {
+ // Once Node observes the leader's exit, taskkill /T cannot reclaim orphaned
+ // descendants through its PID, which may be reused. Skip stale-PID cleanup.
+ if (childProcess.exitCode !== null || childProcess.signalCode !== null) {
+ onExit(null)
+ return
+ }
NodeChildProcess.execFile(
"taskkill",
["/pid", String(childProcess.pid!), "/T", "/F"],
{ windowsHide: true },
onExit
)
+}
const make = Effect.gen(function*() {
const fs = yield* FileSystem.FileSystem