From 01ad3bd31931676a235dd5353e32d3361073896f Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Thu, 13 Jun 2024 12:20:28 +0300 Subject: [PATCH] fix shell inference with scoop --- src/shell/infer/windows.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/shell/infer/windows.rs b/src/shell/infer/windows.rs index 89c3749f0..0abda183b 100644 --- a/src/shell/infer/windows.rs +++ b/src/shell/infer/windows.rs @@ -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> { 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| { @@ -34,6 +36,7 @@ pub fn infer_shell() -> Option> { return Some(shell); } } else { + warn!("process not found for {pid}"); current_pid = None; } }