File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ git2 = "0.14.0"
45
45
nix = " 0.20.0"
46
46
47
47
[target .'cfg(windows)' .dependencies ]
48
- winapi = " 0.3 "
48
+ windows-sys = { version = " 0.36.1 " , features = [ " Win32_Foundation " , " Win32_System_Threading " ]}
49
49
50
50
[dev-dependencies ]
51
51
env_logger = " 0.8"
Original file line number Diff line number Diff line change @@ -3,16 +3,15 @@ use crate::cmd::KillFailedError;
3
3
use failure:: { bail, Error } ;
4
4
use std:: fs:: File ;
5
5
use std:: path:: Path ;
6
- use winapi:: um:: handleapi:: CloseHandle ;
7
- use winapi:: um:: processthreadsapi:: { OpenProcess , TerminateProcess } ;
8
- use winapi:: um:: winnt:: PROCESS_TERMINATE ;
6
+ use windows_sys:: Win32 :: Foundation :: CloseHandle ;
7
+ use windows_sys:: Win32 :: System :: Threading :: { OpenProcess , TerminateProcess , PROCESS_TERMINATE } ;
9
8
10
9
pub ( crate ) fn kill_process ( id : u32 ) -> Result < ( ) , KillFailedError > {
11
10
let error = Err ( KillFailedError { pid : id } ) ;
12
11
13
12
unsafe {
14
13
let handle = OpenProcess ( PROCESS_TERMINATE , 0 , id) ;
15
- if handle. is_null ( ) {
14
+ if handle == 0 || handle == - 1 {
16
15
return error;
17
16
}
18
17
if TerminateProcess ( handle, 101 ) == 0 {
You can’t perform that action at this time.
0 commit comments