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

Allowing the runtime to correctly hook into long-named Windows processes on Linux #754

Merged
merged 4 commits into from
Jan 20, 2024
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
13 changes: 12 additions & 1 deletion crates/livesplit-auto-splitting/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,21 @@ impl ProcessList {
&'process self,
name: &'both str,
) -> impl Iterator<Item = &'process sysinfo::Process> + 'both {
let name = name.as_bytes();

// On Linux the process name is limited to 15 bytes. So we ensure that
// we don't compare more than that. This may lead to false positives
// where we may find the wrong process, but it's better than not finding
// it at all. We could also try to look at the entire path, but
// apparently the path may be something entirely different in emulated
// situations like with Wine.
#[cfg(target_os = "linux")]
let name = &name[..name.len().min(15)];

self.system
.processes()
.values()
.filter(move |p| p.name() == name)
.filter(move |p| p.name().as_bytes() == name)
}

pub fn is_open(&self, pid: sysinfo::Pid) -> bool {
Expand Down
Loading