Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the socket path in a temporary directory #1

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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()
}
}
Loading