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(mcp): stop linux shell probes from suspending tauri dev

Pham Huy Hoangeb234637a465
diff --git a/Cargo.lock b/Cargo.lock
index 4f61a5ea5f..3e60c835a0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2162,6 +2162,7 @@ dependencies = [
"grep",
"gtk",
"ignore",
+ "libc",
"libloading 0.8.9",
"log",
"minisign-verify",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 6df20722d1..b0d9aabfe8 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -95,6 +95,7 @@ objc2-foundation = { version = "0.3.2", default-features = false, features = ["N
[target.'cfg(target_os = "linux")'.dependencies]
libloading = "0.8"
gtk = "0.18"
+libc = "0.2"
[target.'cfg(target_os = "windows")'.dependencies]
# 与 vendored wry / tauri-runtime-wry 同版本(Cargo.lock 只有一份 0.38.x),用于在
diff --git a/src-tauri/src/commands/mcp.rs b/src-tauri/src/commands/mcp.rs
index ea49318816..f4dd6518e9 100644
--- a/src-tauri/src/commands/mcp.rs
+++ b/src-tauri/src/commands/mcp.rs
@@ -756,7 +756,7 @@ fn user_shell_node_candidate() -> Option<NodeRuntimeCandidate> {
shell_quote(SHELL_COMMAND_MARKER)
);
let (shell, shell_args) = user_shell_invocation_args(&script);
- let output = run_command(&shell, &shell_args).ok()?;
+ let output = run_user_shell_command(&shell, &shell_args).ok()?;
if !output.success {
return None;
}
@@ -1575,12 +1575,28 @@ fn windows_shell_quote(value: &str) -> String {
fn run_command_through_user_shell(command: &str, args: &[&str]) -> Result<CommandOutput, String> {
let script = shell_command_script(command, args);
let (shell, shell_args) = user_shell_invocation_args(&script);
- let shell_arg_refs = shell_args.iter().map(String::as_str).collect::<Vec<_>>();
- let mut output = run_command(&shell, &shell_arg_refs)?;
+ let mut output = run_user_shell_command(&shell, &shell_args)?;
output.stdout = stdout_after_shell_marker(&output.stdout);
Ok(output)
}
+#[cfg(not(windows))]
+fn run_user_shell_command(shell: &str, args: &[String]) -> Result<CommandOutput, String> {
+ let mut command = dbx_core::process::new_std_command(shell);
+ command.args(args);
+ #[cfg(target_os = "linux")]
+ {
+ use std::os::unix::process::CommandExt;
+
+ // Interactive shells can use /dev/tty even when stdin is piped. Give
+ // Linux probes their own session so they cannot suspend the app.
+ unsafe {
+ command.pre_exec(|| if libc::setsid() == -1 { Err(std::io::Error::last_os_error()) } else { Ok(()) });
+ }
+ }
+ command_output_from_process(command)
+}
+
#[cfg(not(windows))]
fn user_shell_invocation_args(script: &str) -> (String, Vec<String>) {
let shell = env::var("SHELL").ok().filter(|value| !value.trim().is_empty()).unwrap_or_else(default_user_shell);