(pid: i32)
| 488 | } |
| 489 | |
| 490 | async fn ps_process_for_pid(pid: i32) -> Option<PsProcess> { |
| 491 | let output = timeout( |
| 492 | PROCESS_SAMPLE_TIMEOUT, |
| 493 | Command::new("ps") |
| 494 | .args([ |
| 495 | "-p", |
| 496 | &pid.to_string(), |
| 497 | "-o", |
| 498 | "pid=,ppid=,state=,%cpu=,rss=,command=", |
| 499 | ]) |
| 500 | .output(), |
| 501 | ) |
| 502 | .await |
| 503 | .ok()? |
| 504 | .ok()?; |
| 505 | if !output.status.success() { |
| 506 | return None; |
| 507 | } |
| 508 | String::from_utf8_lossy(&output.stdout) |
| 509 | .lines() |
| 510 | .find_map(parse_ps_line) |
| 511 | } |
| 512 | |
| 513 | fn parse_ps_line(line: &str) -> Option<PsProcess> { |
| 514 | let trimmed = line.trim(); |
no test coverage detected