mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-19 16:04:44 +00:00
Make sure we wait for the executable to finish and propagate error code
This commit is contained in:
parent
6bd033c369
commit
30e8286d53
3 changed files with 16 additions and 19 deletions
|
@ -15,4 +15,7 @@ path = "src/bin.rs"
|
|||
|
||||
[dependencies]
|
||||
detours-sys = "0.1"
|
||||
clap = "2.33"
|
||||
clap = "2.33"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = ["processthreadsapi", "std", "synchapi"] }
|
27
src/bin.rs
27
src/bin.rs
|
@ -1,5 +1,6 @@
|
|||
extern crate clap;
|
||||
extern crate detours_sys;
|
||||
extern crate winapi;
|
||||
|
||||
use std::error::Error;
|
||||
use std::ffi::OsStr;
|
||||
|
@ -7,6 +8,10 @@ use std::mem;
|
|||
use std::os::windows::ffi::OsStrExt;
|
||||
use std::ptr;
|
||||
|
||||
use winapi::um::processthreadsapi::{GetExitCodeProcess, ResumeThread};
|
||||
use winapi::um::synchapi::WaitForSingleObject;
|
||||
use winapi::um::winbase::{INFINITE, WAIT_FAILED};
|
||||
|
||||
use clap::{App, AppSettings, Arg};
|
||||
|
||||
#[macro_use]
|
||||
|
@ -63,23 +68,13 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
"nvcuda_redirect.dll".as_ptr() as *const i8,
|
||||
Option::None
|
||||
),
|
||||
0
|
||||
|x| x == 0
|
||||
);
|
||||
Ok(())
|
||||
/*
|
||||
|
||||
cmd_line.as_mut_ptr(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
0,
|
||||
0x10,
|
||||
ptr::null_mut(),
|
||||
ptr::null(),
|
||||
&mut startup_info as *mut _,
|
||||
&mut proc_info as *mut _,
|
||||
"nvcuda_redirect.dll".as_ptr() as *const i8,
|
||||
Option::None,
|
||||
*/
|
||||
os_call!(ResumeThread(proc_info.hThread), |x| x as i32 != -1);
|
||||
os_call!(WaitForSingleObject(proc_info.hProcess, INFINITE), |x| x != WAIT_FAILED);
|
||||
let mut child_exit_code : u32 = 0;
|
||||
os_call!(GetExitCodeProcess(proc_info.hProcess, &mut child_exit_code as *mut _), |x| x != 0);
|
||||
std::process::exit(child_exit_code as i32)
|
||||
}
|
||||
|
||||
fn copy_to(from: &OsStr, to: &mut Vec<u16>) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use std::error;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
|
||||
|
@ -50,7 +49,7 @@ macro_rules! last_ident {
|
|||
macro_rules! os_call {
|
||||
($($path:ident)::+ ($($args:expr),*), $success:expr) => {
|
||||
let result = unsafe{ $($path)::+ ($($args),+) };
|
||||
if result != $success {
|
||||
if !($success)(result) {
|
||||
let name = last_ident!($($path),+);
|
||||
let err_code = $crate::win::errno();
|
||||
Err($crate::win::OsError{
|
||||
|
|
Loading…
Add table
Reference in a new issue