Skip to content

Commit

Permalink
Merge pull request #267 from Eh2406/windows
Browse files Browse the repository at this point in the history
allow building on Windows
  • Loading branch information
pietroalbini committed Jul 9, 2018
2 parents 4aeded0 + d9364ee commit 1ce204a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -47,6 +47,7 @@ tokio-timer = "0.1.1"
toml = "0.4.6"
url = "1.1"
walkdir = "2"
winapi = "0.3"
regex = "0.2.10"
ring = "0.12.1"
rusqlite = { version = "0.13.0", features = ["chrono"] }
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -13,6 +13,7 @@ extern crate handlebars;
extern crate hyper;
#[macro_use]
extern crate lazy_static;
#[cfg(not(windows))]
extern crate libc;
extern crate mime;
extern crate petgraph;
Expand Down Expand Up @@ -55,6 +56,8 @@ extern crate toml;
#[macro_use]
extern crate url;
extern crate walkdir;
#[cfg(windows)]
extern crate winapi;

pub mod agent;
#[macro_use]
Expand Down
9 changes: 6 additions & 3 deletions src/run.rs
Expand Up @@ -181,9 +181,12 @@ fn log_command(mut cmd: Command, capture: bool, quiet: bool) -> Result<ProcessOu
#[cfg(windows)]
fn kill_process(id: u32) {
unsafe {
let handle = kernel32::OpenProcess(winapi::winnt::PROCESS_TERMINATE, 0, id);
kernel32::TerminateProcess(handle, 101);
if kernel32::CloseHandle(handle) == 0 {
use winapi::um::handleapi::CloseHandle;
use winapi::um::processthreadsapi::{OpenProcess, TerminateProcess};
use winapi::um::winnt::PROCESS_TERMINATE;
let handle = OpenProcess(PROCESS_TERMINATE, 0, id);
TerminateProcess(handle, 101);
if CloseHandle(handle) == 0 {
panic!("CloseHandle for process {} failed", id);
}
};
Expand Down

0 comments on commit 1ce204a

Please sign in to comment.