1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

tail: migrate winapi to windows-sys crate

This commit is contained in:
Niyaz Nigmatullin 2022-10-19 23:40:00 +03:00 committed by Niyaz Nigmatullin
parent ff30cacbe1
commit 5ef1745960
3 changed files with 10 additions and 15 deletions

2
Cargo.lock generated
View file

@ -2968,8 +2968,8 @@ dependencies = [
"notify",
"same-file",
"uucore",
"winapi",
"winapi-util",
"windows-sys 0.42.0",
]
[[package]]

View file

@ -24,7 +24,7 @@ uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=[
same-file = "1.0.6"
[target.'cfg(windows)'.dependencies]
winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] }
windows-sys = { version = "0.42.0", default-features = false, features = ["Win32_System_Threading", "Win32_Foundation"] }
winapi-util = { version="0.1.5" }
[target.'cfg(unix)'.dependencies]

View file

@ -6,17 +6,12 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use windows_sys::Win32::Foundation::{CloseHandle, BOOL, HANDLE, WAIT_FAILED, WAIT_OBJECT_0};
use windows_sys::Win32::System::Threading::{
OpenProcess, WaitForSingleObject, PROCESS_SYNCHRONIZE,
};
extern crate winapi;
use self::winapi::shared::minwindef::DWORD;
use self::winapi::um::handleapi::CloseHandle;
use self::winapi::um::processthreadsapi::OpenProcess;
use self::winapi::um::synchapi::WaitForSingleObject;
use self::winapi::um::winbase::{WAIT_FAILED, WAIT_OBJECT_0};
use self::winapi::um::winnt::{HANDLE, SYNCHRONIZE};
pub type Pid = DWORD;
pub type Pid = u32;
pub struct ProcessChecker {
dead: bool,
@ -26,10 +21,10 @@ pub struct ProcessChecker {
impl ProcessChecker {
pub fn new(process_id: self::Pid) -> Self {
#[allow(non_snake_case)]
let FALSE = 0i32;
let h = unsafe { OpenProcess(SYNCHRONIZE, FALSE, process_id as DWORD) };
let FALSE: BOOL = 0;
let h = unsafe { OpenProcess(PROCESS_SYNCHRONIZE, FALSE, process_id) };
Self {
dead: h.is_null(),
dead: h == 0,
handle: h,
}
}