Below is a snippet of the code. Everything is properly defined. Issue is I get an error, manager_state does not live long enough when I try compiling. Any help appreciated
loop {
match child.as_mut().unwrap().try_wait() {
Ok(Some(status)) => {
tx.send(WatcherMessage::Stopped {
name: name.to_string(),
output: std::process::Output {
status,
stdout: Vec::new(),
stderr: Vec::new(),
},
})
.unwrap();
break;
}
Ok(None) => {
let manager_state = state.lock().unwrap();
let mutex = manager_state.mutex.lock().unwrap();
// Wait for the condvar to be notified
match manager_state.condvar.wait(mutex) {
Ok(_) => {
println!("condvar notified");
child.as_mut().unwrap().kill().unwrap();
}
Err(e) => {
println!("error attempting to wait: {e}");
break;
}
}
}
Err(e) => {
println!("error attempting to wait: {e}");
break;
}
}
}