diff --git a/src/lib.rs b/src/lib.rs index 3c6b80a..9dfda0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,7 +131,7 @@ impl MinidumperChild { } else { // We use a unique socket name because we don't share the crash reporter // processes between different instances of the app. - let socket_name = uuid::Uuid::new_v4().to_string(); + let socket_name = make_socket_name(uuid::Uuid::new_v4()); std::env::current_exe() .and_then(|current_exe| { @@ -156,3 +156,17 @@ impl MinidumperChild { } } } + +pub fn make_socket_name(session_id: uuid::Uuid) -> String { + if cfg!(any(target_os = "linux", target_os = "android")) { + format!("temp-socket-{}", session_id.simple()) + } else { + // For platforms without abstract uds, put the pipe in the + // temporary directory so that the OS can clean it up, rather than + // polluting the cwd due to annoying file deletion problems, + // particularly on Windows + let mut td = std::env::temp_dir(); + td.push(format!("temp-socket-{}", session_id.simple())); + td.to_string_lossy().to_string() + } +}