mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-08-03 14:50:53 +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
|
@ -16,3 +16,6 @@ path = "src/bin.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
detours-sys = "0.1"
|
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 clap;
|
||||||
extern crate detours_sys;
|
extern crate detours_sys;
|
||||||
|
extern crate winapi;
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
@ -7,6 +8,10 @@ use std::mem;
|
||||||
use std::os::windows::ffi::OsStrExt;
|
use std::os::windows::ffi::OsStrExt;
|
||||||
use std::ptr;
|
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};
|
use clap::{App, AppSettings, Arg};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -63,23 +68,13 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
"nvcuda_redirect.dll".as_ptr() as *const i8,
|
"nvcuda_redirect.dll".as_ptr() as *const i8,
|
||||||
Option::None
|
Option::None
|
||||||
),
|
),
|
||||||
0
|
|x| x == 0
|
||||||
);
|
);
|
||||||
Ok(())
|
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;
|
||||||
cmd_line.as_mut_ptr(),
|
os_call!(GetExitCodeProcess(proc_info.hProcess, &mut child_exit_code as *mut _), |x| x != 0);
|
||||||
ptr::null_mut(),
|
std::process::exit(child_exit_code as i32)
|
||||||
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,
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_to(from: &OsStr, to: &mut Vec<u16>) {
|
fn copy_to(from: &OsStr, to: &mut Vec<u16>) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::error::Error;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ macro_rules! last_ident {
|
||||||
macro_rules! os_call {
|
macro_rules! os_call {
|
||||||
($($path:ident)::+ ($($args:expr),*), $success:expr) => {
|
($($path:ident)::+ ($($args:expr),*), $success:expr) => {
|
||||||
let result = unsafe{ $($path)::+ ($($args),+) };
|
let result = unsafe{ $($path)::+ ($($args),+) };
|
||||||
if result != $success {
|
if !($success)(result) {
|
||||||
let name = last_ident!($($path),+);
|
let name = last_ident!($($path),+);
|
||||||
let err_code = $crate::win::errno();
|
let err_code = $crate::win::errno();
|
||||||
Err($crate::win::OsError{
|
Err($crate::win::OsError{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue