Add drop for process

This commit is contained in:
Edwin Cheng 2020-03-31 21:25:52 +08:00
parent e7d1549e13
commit b929d05c74

View File

@ -45,6 +45,12 @@ struct Process {
child: Child,
}
impl Drop for Process {
fn drop(&mut self) {
let _ = self.child.kill();
}
}
impl Process {
fn run(process_path: &Path) -> Result<Process, io::Error> {
let child = Command::new(process_path.clone())
@ -186,8 +192,6 @@ fn client_loop(task_rx: Receiver<Task>, mut process: Process) {
result_tx.send(res).unwrap();
}
}
let _ = process.child.kill();
}
fn send_request(