()
| 469 | } |
| 470 | |
| 471 | async fn list_ps_processes() -> Result<Vec<PsProcess>, AppError> { |
| 472 | let output = timeout( |
| 473 | PROCESS_LIST_TIMEOUT, |
| 474 | Command::new("ps") |
| 475 | .args(["-axo", "pid=,ppid=,state=,%cpu=,rss=,command="]) |
| 476 | .output(), |
| 477 | ) |
| 478 | .await |
| 479 | .map_err(|_| AppError::native("Timed out listing host processes."))? |
| 480 | .map_err(|error| AppError::native(format!("Unable to list host processes: {error}")))?; |
| 481 | if !output.status.success() { |
| 482 | return Err(AppError::native("Unable to list host processes.")); |
| 483 | } |
| 484 | Ok(String::from_utf8_lossy(&output.stdout) |
| 485 | .lines() |
| 486 | .filter_map(parse_ps_line) |
| 487 | .collect()) |
| 488 | } |
| 489 | |
| 490 | async fn ps_process_for_pid(pid: i32) -> Option<PsProcess> { |
| 491 | let output = timeout( |
no test coverage detected