MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / ps_process_for_pid

Function ps_process_for_pid

packages/server/src/performance.rs:490–511  ·  view source on GitHub ↗
(pid: i32)

Source from the content-addressed store, hash-verified

488}
489
490async 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
513fn parse_ps_line(line: &str) -> Option<PsProcess> {
514 let trimmed = line.trim();

Callers 2

sample_processFunction · 0.85

Calls 1

outputMethod · 0.65

Tested by

no test coverage detected