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

Function list_ps_processes

packages/server/src/performance.rs:471–488  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

469}
470
471async 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
490async fn ps_process_for_pid(pid: i32) -> Option<PsProcess> {
491 let output = timeout(

Callers 2

list_processesMethod · 0.85
snapshotMethod · 0.85

Calls 1

outputMethod · 0.65

Tested by

no test coverage detected