惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
V
V2EX
博客园 - 叶小钗
雷峰网
雷峰网
小众软件
小众软件
量子位
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
G
Google Developers Blog
博客园_首页
博客园 - Franky
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(ui): clean up wrapper signal descendants · openclaw/o...
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main

@@ -102,27 +102,55 @@ function runSpawnCall(spawnCall, label) {

102102

}

103103104104

let forwardedSignal = null;

105+

let forwardedSignalPids = [];

105106

let forceKillTimer = null;

107+

let forwardedSignalDrainTimer = null;

108+

const clearForwardedSignalTimers = () => {

109+

if (forceKillTimer) {

110+

clearTimeout(forceKillTimer);

111+

forceKillTimer = null;

112+

}

113+

if (forwardedSignalDrainTimer) {

114+

clearInterval(forwardedSignalDrainTimer);

115+

forwardedSignalDrainTimer = null;

116+

}

117+

};

118+

const finishForwardedSignal = () => {

119+

cleanupSignalHandlers();

120+

process.kill(process.pid, forwardedSignal);

121+

};

122+

const waitForForwardedSignalChildren = () => {

123+

if (!forwardedSignal || processTreeIsAlive(forwardedSignalPids)) {

124+

return;

125+

}

126+

finishForwardedSignal();

127+

};

106128

// Keep UI dev children in the foreground process group for native TTY

107-

// resize/job-control behavior. Forward direct wrapper shutdown signals.

129+

// resize/job-control behavior. Forward wrapper shutdown signals to the

130+

// captured child tree instead of using a detached process group.

108131

const forwardedSignals = ["SIGTERM", "SIGHUP"];

109132

const signalHandlers = new Map(

110133

forwardedSignals.map((signal) => [

111134

signal,

112135

() => {

113-

forwardedSignal ??= signal;

114-

child.kill(signal);

115-

forceKillTimer ??= setTimeout(() => child.kill("SIGKILL"), 5_000);

136+

if (!forwardedSignal) {

137+

forwardedSignal = signal;

138+

forwardedSignalPids = collectChildProcessTreePids(child);

139+

signalProcessTree(child, signal, forwardedSignalPids);

140+

forwardedSignalDrainTimer = setInterval(waitForForwardedSignalChildren, 25);

141+

forceKillTimer = setTimeout(() => {

142+

signalProcessTree(child, "SIGKILL", forwardedSignalPids);

143+

}, 5_000);

144+

forceKillTimer.unref?.();

145+

}

116146

},

117147

]),

118148

);

119149

const cleanupSignalHandlers = () => {

120150

for (const [signal, handler] of signalHandlers) {

121151

process.off(signal, handler);

122152

}

123-

if (forceKillTimer) {

124-

clearTimeout(forceKillTimer);

125-

}

153+

clearForwardedSignalTimers();

126154

};

127155

for (const [signal, handler] of signalHandlers) {

128156

process.on(signal, handler);

@@ -134,11 +162,11 @@ function runSpawnCall(spawnCall, label) {

134162

process.exit(1);

135163

});

136164

child.on("exit", (code, signal) => {

137-

cleanupSignalHandlers();

138165

if (forwardedSignal) {

139-

process.kill(process.pid, forwardedSignal);

166+

waitForForwardedSignalChildren();

140167

return;

141168

}

169+

cleanupSignalHandlers();

142170

if (signal) {

143171

process.kill(process.pid, signal);

144172

return;

@@ -149,6 +177,66 @@ function runSpawnCall(spawnCall, label) {

149177

});

150178

}

151179180+

function collectChildProcessTreePids(child) {

181+

if (process.platform === "win32" || typeof child.pid !== "number") {

182+

return typeof child.pid === "number" ? [child.pid] : [];

183+

}

184+

const ps = spawnSync("ps", ["-axo", "pid=,ppid="], { encoding: "utf8" });

185+

if (ps.status !== 0) {

186+

return [child.pid];

187+

}

188+

const childrenByParent = new Map();

189+

for (const line of ps.stdout.split("\n")) {

190+

const match = line.trim().match(/^(\d+)\s+(\d+)$/u);

191+

if (!match) {

192+

continue;

193+

}

194+

const pid = Number(match[1]);

195+

const ppid = Number(match[2]);

196+

const siblings = childrenByParent.get(ppid) ?? [];

197+

siblings.push(pid);

198+

childrenByParent.set(ppid, siblings);

199+

}

200+

const pids = [child.pid];

201+

for (const parentPid of pids) {

202+

for (const pid of childrenByParent.get(parentPid) ?? []) {

203+

pids.push(pid);

204+

}

205+

}

206+

return [...new Set(pids)];

207+

}

208+209+

function processTreeIsAlive(pids) {

210+

return pids.some((pid) => {

211+

try {

212+

process.kill(pid, 0);

213+

return true;

214+

} catch (error) {

215+

return error?.code === "EPERM";

216+

}

217+

});

218+

}

219+220+

function signalProcessTree(child, signal, pids) {

221+

if (process.platform === "win32") {

222+

child.kill(signal);

223+

return;

224+

}

225+

if (pids.length === 0) {

226+

child.kill(signal);

227+

return;

228+

}

229+

for (const pid of pids.toReversed()) {

230+

try {

231+

process.kill(pid, signal);

232+

} catch (error) {

233+

if (error?.code !== "ESRCH") {

234+

throw error;

235+

}

236+

}

237+

}

238+

}

239+152240

function run(cmd, args) {

153241

runSpawnCall(resolveSpawnCall(cmd, args), cmd);

154242

}