Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow building on Windows #267

Merged
merged 1 commit into from Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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