iriai-build 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/agent-process.js +8 -5
- package/package.json +1 -1
- package/v3/agent-supervisor.js +8 -3
package/lib/agent-process.js
CHANGED
|
@@ -67,7 +67,7 @@ class AgentProcess extends EventEmitter {
|
|
|
67
67
|
cwd: this.cwd,
|
|
68
68
|
env,
|
|
69
69
|
stdio: ["ignore", "pipe", "pipe"],
|
|
70
|
-
detached:
|
|
70
|
+
detached: true, // own process group so kill(-pid) reaps child shells
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
this.pid = this._process.pid;
|
|
@@ -129,19 +129,22 @@ class AgentProcess extends EventEmitter {
|
|
|
129
129
|
if (!this._process || this._killed || this.exited) return;
|
|
130
130
|
this._killed = true;
|
|
131
131
|
|
|
132
|
+
// Kill the entire process group (negative PID) to reap child shell
|
|
133
|
+
// subprocesses (e.g. poll loops spawned by claude CLI's bash tool).
|
|
132
134
|
try {
|
|
133
|
-
process.kill(this.pid, signal);
|
|
135
|
+
process.kill(-this.pid, signal);
|
|
134
136
|
} catch {
|
|
135
|
-
|
|
137
|
+
// Fallback to killing just the process if group kill fails
|
|
138
|
+
try { process.kill(this.pid, signal); } catch { /* already gone */ }
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
// Escalate to SIGKILL after 5s grace period
|
|
139
142
|
if (signal !== "SIGKILL") {
|
|
140
143
|
this._killTimer = setTimeout(() => {
|
|
141
144
|
try {
|
|
142
|
-
if (!this.exited) process.kill(this.pid, "SIGKILL");
|
|
145
|
+
if (!this.exited) process.kill(-this.pid, "SIGKILL");
|
|
143
146
|
} catch {
|
|
144
|
-
/* already gone */
|
|
147
|
+
try { if (!this.exited) process.kill(this.pid, "SIGKILL"); } catch { /* already gone */ }
|
|
145
148
|
}
|
|
146
149
|
}, 5000);
|
|
147
150
|
}
|
package/package.json
CHANGED
package/v3/agent-supervisor.js
CHANGED
|
@@ -38,8 +38,11 @@ export class AgentSupervisor extends EventEmitter {
|
|
|
38
38
|
|
|
39
39
|
// Also kill by DB PID in case process was orphaned
|
|
40
40
|
// (exited from supervisor tracking but OS process still alive)
|
|
41
|
+
// Kill process group (-pid) to reap child shells too.
|
|
41
42
|
if (agent.pid) {
|
|
42
|
-
try { process.kill(agent.pid, "SIGKILL"); } catch {
|
|
43
|
+
try { process.kill(-agent.pid, "SIGKILL"); } catch {
|
|
44
|
+
try { process.kill(agent.pid, "SIGKILL"); } catch { /* already dead */ }
|
|
45
|
+
}
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
ensureDir(agent.signal_dir);
|
|
@@ -300,8 +303,10 @@ export class AgentSupervisor extends EventEmitter {
|
|
|
300
303
|
continue;
|
|
301
304
|
}
|
|
302
305
|
if (this.isAlive(pid)) {
|
|
303
|
-
console.log(`[supervisor] Killing orphaned PID ${pid} in ${path.basename(dir)}`);
|
|
304
|
-
try { process.kill(pid, "SIGTERM"); } catch {
|
|
306
|
+
console.log(`[supervisor] Killing orphaned PID ${pid} (+ group) in ${path.basename(dir)}`);
|
|
307
|
+
try { process.kill(-pid, "SIGTERM"); } catch {
|
|
308
|
+
try { process.kill(pid, "SIGTERM"); } catch { /* ok */ }
|
|
309
|
+
}
|
|
305
310
|
}
|
|
306
311
|
fs.unlinkSync(runningFile);
|
|
307
312
|
} catch { /* ok */ }
|