Debian Codegraph @

src/windows/mod.rs

raw symbols SCIP
1 use std::mem::MaybeUninit;
2
3 use windows_sys::Win32::Foundation::{FALSE, STILL_ACTIVE};
4 use windows_sys::Win32::System::Threading::GetExitCodeProcess;
5
6 use self::handle::Handle;
7 use crate::{Pid, State};
8
9 mod handle;
10
11 pub fn state(pid: Pid) -> State {
12 let handle = match Handle::open(pid) {
13 Some(handle) => handle,
14 None => return State::Unknown,
15 };
16
17 let mut status = MaybeUninit::uninit();
18 unsafe {
19 if GetExitCodeProcess(*handle, status.as_mut_ptr()) == FALSE {
20 return State::Unknown;
21 }
22
23 if status.assume_init() == STILL_ACTIVE as u32 {
24 State::Alive
25 } else {
26 State::Dead
27 }
28 }
29 }