Skip to content

Commit

Permalink
fix shell inference with scoop
Browse files Browse the repository at this point in the history
  • Loading branch information
Schniz committed Jun 13, 2024
1 parent 01ec475 commit 01ad3bd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/shell/infer/windows.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#![cfg(not(unix))]

use crate::shell::Shell;
use log::warn;
use sysinfo::System;
use log::{debug, warn};
use sysinfo::{ProcessRefreshKind, System, UpdateKind};

pub fn infer_shell() -> Option<Box<dyn Shell>> {
let mut system = System::new();
let mut current_pid = sysinfo::get_current_pid().ok();
system.refresh_processes();

system
.refresh_processes_specifics(ProcessRefreshKind::new().with_exe(UpdateKind::OnlyIfNotSet));

while let Some(pid) = current_pid {
system.refresh_process(pid);
if let Some(process) = system.process(pid) {
current_pid = process.parent();
debug!("pid {pid} parent process is {current_pid:?}");
let process_name = process
.exe()
.and_then(|x| {
Expand All @@ -34,6 +36,7 @@ pub fn infer_shell() -> Option<Box<dyn Shell>> {
return Some(shell);
}
} else {
warn!("process not found for {pid}");
current_pid = None;
}
}
Expand Down

0 comments on commit 01ad3bd

Please sign in to comment.