Add drop for process
This commit is contained in:
parent
e7d1549e13
commit
b929d05c74
1 changed files with 6 additions and 2 deletions
|
@ -45,6 +45,12 @@ struct Process {
|
||||||
child: Child,
|
child: Child,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for Process {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let _ = self.child.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Process {
|
impl Process {
|
||||||
fn run(process_path: &Path) -> Result<Process, io::Error> {
|
fn run(process_path: &Path) -> Result<Process, io::Error> {
|
||||||
let child = Command::new(process_path.clone())
|
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();
|
result_tx.send(res).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = process.child.kill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_request(
|
fn send_request(
|
||||||
|
|
Loading…
Reference in a new issue