| 321 | } |
| 322 | |
| 323 | async fn wait_on_process( |
| 324 | mut process: Child, |
| 325 | kill_rx: oneshot::Receiver<()>, |
| 326 | ) -> (bool, Result<ExitStatus>) { |
| 327 | let (killed, result) = tokio::select! { |
| 328 | _ = kill_rx => { |
| 329 | info!("Killing process"); |
| 330 | if let Err(err) = process.kill().await { |
| 331 | error!("Failed to kill process: {err:?}"); |
| 332 | } |
| 333 | (true, process.wait().await) |
| 334 | } |
| 335 | result = process.wait() => { |
| 336 | (false, result) |
| 337 | } |
| 338 | }; |
| 339 | if killed { |
| 340 | info!("Killed"); |
| 341 | } |
| 342 | (killed, result.map_err(Into::into)) |
| 343 | } |
| 344 | |
| 345 | async fn redirect(mut input: impl AsyncRead + Unpin, to: String) { |
| 346 | async fn consume(input: &mut (impl AsyncRead + Unpin)) -> Result<()> { |