MCPcopy Create free account
hub / github.com/PowerShell/DSC / get_task_list

Function get_task_list

resources/process/src/main.rs:11–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9use crate::process_info::ProcessInfo;
10
11fn get_task_list() -> Vec<ProcessInfo>
12{
13 let mut result = Vec::new();
14 let mut s = System::new();
15 s.refresh_processes(ProcessesToUpdate::All, true);
16 let mut count = 0;
17 for (pid, process) in s.processes() {
18 let mut p = ProcessInfo::new();
19 p.pid = pid.as_u32();
20 p.name = process.name().to_string_lossy().to_string();
21 p.cmdline = format!("{:?}", process.cmd());
22 result.push(p);
23 count += 1;
24 if count > 3 {
25 // limit to 3 processes as this is just for testing
26 break;
27 }
28 }
29
30 result
31}
32
33fn help() {
34 println!("usage: process list");

Callers 1

mainFunction · 0.85

Calls 2

newFunction · 0.50
nameMethod · 0.45

Tested by

no test coverage detected