not close connection if failed to start cm due to no explorer.exe (#8290)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
parent
0bb537b872
commit
8de5f3f0d3
@ -67,6 +67,7 @@ use winreg::enums::*;
|
|||||||
use winreg::RegKey;
|
use winreg::RegKey;
|
||||||
|
|
||||||
pub const FLUTTER_RUNNER_WIN32_WINDOW_CLASS: &'static str = "FLUTTER_RUNNER_WIN32_WINDOW"; // main window, install window
|
pub const FLUTTER_RUNNER_WIN32_WINDOW_CLASS: &'static str = "FLUTTER_RUNNER_WIN32_WINDOW"; // main window, install window
|
||||||
|
pub const EXPLORER_EXE: &'static str = "explorer.exe";
|
||||||
|
|
||||||
pub fn get_focused_display(displays: Vec<DisplayInfo>) -> Option<usize> {
|
pub fn get_focused_display(displays: Vec<DisplayInfo>) -> Option<usize> {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -668,6 +669,14 @@ pub fn run_as_user(arg: Vec<&str>) -> ResultType<Option<std::process::Child>> {
|
|||||||
let wstr = wstr.as_ptr();
|
let wstr = wstr.as_ptr();
|
||||||
let h = unsafe { LaunchProcessWin(wstr, session_id, TRUE) };
|
let h = unsafe { LaunchProcessWin(wstr, session_id, TRUE) };
|
||||||
if h.is_null() {
|
if h.is_null() {
|
||||||
|
if !is_process_running(EXPLORER_EXE, session_id) {
|
||||||
|
bail!(
|
||||||
|
"Failed to launch {:?} with session id {}: no process {}",
|
||||||
|
arg,
|
||||||
|
session_id,
|
||||||
|
EXPLORER_EXE
|
||||||
|
);
|
||||||
|
}
|
||||||
bail!(
|
bail!(
|
||||||
"Failed to launch {:?} with session id {}: {}",
|
"Failed to launch {:?} with session id {}: {}",
|
||||||
arg,
|
arg,
|
||||||
@ -2031,6 +2040,24 @@ pub fn is_process_consent_running() -> ResultType<bool> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
Ok(output.status.success() && !output.stdout.is_empty())
|
Ok(output.status.success() && !output.stdout.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_process_running(exe: &str, session_id: u32) -> bool {
|
||||||
|
use hbb_common::sysinfo::System;
|
||||||
|
let mut sys = System::new();
|
||||||
|
sys.refresh_processes();
|
||||||
|
for (_, p) in sys.processes().iter() {
|
||||||
|
if p.session_id() == Some((session_id as usize).into())
|
||||||
|
&& p.exe()
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_lowercase()
|
||||||
|
.contains(&exe.to_lowercase())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
pub struct WakeLock(u32);
|
pub struct WakeLock(u32);
|
||||||
// Failed to compile keepawake-rs on i686
|
// Failed to compile keepawake-rs on i686
|
||||||
impl WakeLock {
|
impl WakeLock {
|
||||||
|
@ -1595,7 +1595,9 @@ impl Connection {
|
|||||||
{
|
{
|
||||||
log::error!("ipc to connection manager exit: {}", err);
|
log::error!("ipc to connection manager exit: {}", err);
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if !crate::platform::is_prelogin() {
|
if !crate::platform::is_prelogin()
|
||||||
|
&& !err.to_string().contains(crate::platform::EXPLORER_EXE)
|
||||||
|
{
|
||||||
allow_err!(tx_from_cm_clone.send(Data::CmErr(err.to_string())));
|
allow_err!(tx_from_cm_clone.send(Data::CmErr(err.to_string())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user