From cd538581907286b5391647f91ccfefe99a6c93c4 Mon Sep 17 00:00:00 2001 From: atagen Date: Wed, 25 Jun 2025 01:55:53 +1000 Subject: [PATCH] fix: refuse to clobber active socket --- daemon/ipc.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/daemon/ipc.rs b/daemon/ipc.rs index ebcff06..6c8fefc 100644 --- a/daemon/ipc.rs +++ b/daemon/ipc.rs @@ -47,6 +47,16 @@ async fn create_provider_socket(name: &'static str, socket: &'static str) -> Res let mut sock_path = get_run_path()?; sock_path.push(format!("{}.sock", socket)); if smol::fs::metadata(&sock_path).await.is_ok() { + for entry in smol::fs::read_to_string("/proc/net/unix").await?.lines() { + if entry.contains(socket) { + tracing::error!( + "Another instance is already using the {} socket {}!", + name, + socket + ); + return Err(anyhow!("Socket in use")); + } + } tracing::debug!("removing old {} socket", name); smol::fs::remove_file(&sock_path).await?; }