Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: killing backend in linux, it shouldn't kill the app (#1690)

tribhuwan6366df68e2e7
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 21146a55f..4a21db3a4 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -82,7 +82,7 @@ pub async fn stop_screenpipe(
) -> Result<(), String> {
debug!("Killing screenpipe");
- #[cfg(not(target_os = "windows"))]
+ #[cfg(target_os = "macos")]
{
let mut manager = state.0.lock().await;
if let Some(manager) = manager.as_mut() {
@@ -92,10 +92,6 @@ pub async fn stop_screenpipe(
}
}
}
- }
-
- #[cfg(not(target_os = "windows"))]
- {
match tokio::process::Command::new("pkill")
.arg("-9")
.arg("-f")
@@ -138,6 +134,30 @@ pub async fn stop_screenpipe(
}
}
}
+
+ #[cfg(target_os = "linux")]
+ {
+ // -15 from gnu man page
+ // ref: https://www.gnu.org/software/coreutils/manual/html_node/kill-invocation.html
+ let command = format!(
+ "pgrep -x screenpipe | xargs -I {{}} kill -15 {{}}",
+ );
+ match tokio::process::Command::new("sh")
+ .arg("-c")
+ .arg(command)
+ .output()
+ .await
+ {
+ Ok(_) => {
+ debug!("Successfully killed screenpipe processes");
+ Ok(())
+ }
+ Err(e) => {
+ error!("Failed to kill screenpipe processes: {}", e);
+ Err(format!("Failed to kill screenpipe processes: {}", e))
+ }
+ }
+ }
}
#[tauri::command]