diff --git a/src/main.rs b/src/main.rs index d573705..515c48b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,7 @@ mod byte_buffer; use crate::adb_monitor::{AdbMonitor, AdbMonitorCallback}; use std::env; use std::process::Command; +use std::thread; struct AutoAdb { command: Vec, @@ -40,9 +41,17 @@ impl AdbMonitorCallback for AutoAdb { }) .collect::>(); println!("Detected device {}", serial); - let process = Command::new(&cmd[0]).args(cmd.iter().skip(1)).spawn(); - if let Err(err) = process { - eprintln!("Could not execute {:?}: {}", cmd, err); + match Command::new(&cmd[0]).args(cmd.iter().skip(1)).spawn() { + Ok(mut child) => { + thread::spawn(move || { + if let Err(err) = child.wait() { + eprintln!("Could not wait child process: {}", err); + } + }); + } + Err(err) => { + eprintln!("Could not execute {:?}: {}", cmd, err); + } } } }