mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
* Replace error-chain with thiserror in util crate * Replace errorchain with anyhow/thiserror in api * Replace with anyhow/thiserror in updater * Replace with anyhow/thiserror in tauri * Fix error handling on windows
21 lines
565 B
Rust
21 lines
565 B
Rust
use crate::Error;
|
|
|
|
use sysinfo;
|
|
|
|
pub use sysinfo::{Process, ProcessExt, Signal, System, SystemExt};
|
|
|
|
pub fn get_parent_process(system: &mut sysinfo::System) -> Result<&Process, Error> {
|
|
let pid = sysinfo::get_current_pid().unwrap();
|
|
system.refresh_process(pid);
|
|
let current_process = system
|
|
.get_process(pid)
|
|
.ok_or(Error::ParentProcess)?;
|
|
let parent_pid = current_process.parent().ok_or(Error::ParentPID)?;
|
|
let parent_process = system
|
|
.get_process(parent_pid)
|
|
.ok_or(Error::ParentProcess)?;
|
|
|
|
println!("{}", pid);
|
|
Ok(parent_process)
|
|
}
|