Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(agent): prevent zombie processes on agent cleanup

t8y2791d55661e1c
diff --git a/crates/dbx-core/src/db/agent_driver.rs b/crates/dbx-core/src/db/agent_driver.rs
index f669e5f478..1903ef927d 100644
--- a/crates/dbx-core/src/db/agent_driver.rs
+++ b/crates/dbx-core/src/db/agent_driver.rs
@@ -722,8 +722,24 @@ impl AgentDriverClient {
if let Err(e) = self.child.kill() {
log::warn!("Failed to kill agent process: {e}");
}
- // Reap the child to avoid zombie processes
- let _ = self.child.wait();
+ // Reap the child to avoid zombie processes.
+ // Use try_wait() with a timeout instead of blocking wait() to avoid
+ // hanging in Drop during async cleanup. Poll up to 100ms for the
+ // process to exit after kill().
+ for _ in 0..10 {
+ match self.child.try_wait() {
+ Ok(Some(_status)) => return,
+ Ok(None) => std::thread::sleep(Duration::from_millis(10)),
+ Err(e) => {
+ log::warn!("Failed to wait for agent process: {e}");
+ return;
+ }
+ }
+ }
+ // Final blocking wait as a last resort
+ if let Err(e) = self.child.wait() {
+ log::warn!("Final wait failed for agent process: {e}");
+ }
}
pub fn pid(&self) -> u32 {