|
|
@@ -12,54 +12,45 @@ fn main() {
|
|
12
|
12
|
|
|
13
|
13
|
match args.len() {
|
|
14
|
14
|
1 => {
|
|
15
|
|
- match readproc::self_pids() {
|
|
16
|
|
- Ok(pid_tuple) => {
|
|
17
|
|
- let pid = pid_tuple.0;
|
|
18
|
|
- let ppid = pid_tuple.1;
|
|
19
|
|
-
|
|
20
|
|
- // Commands
|
|
21
|
|
- let pid_command = readproc::get_pid_command(pid).unwrap();
|
|
22
|
|
- let ppid_command = readproc::get_pid_command(ppid).unwrap();
|
|
23
|
|
-
|
|
24
|
|
- // Threads
|
|
25
|
|
- let pid_threads = readproc::get_thread_count(pid).unwrap();
|
|
26
|
|
- let ppid_threads = readproc::get_thread_count(ppid).unwrap();
|
|
27
|
|
-
|
|
28
|
|
- // Output for PID and PPID Information
|
|
29
|
|
- println!("My PID : {} - {} running {} threads", pid, pid_command, pid_threads);
|
|
30
|
|
- println!("My PPID: {} - {} running {} threads", ppid, ppid_command, ppid_threads);
|
|
|
15
|
+ if let Ok(pid_tuple) = readproc::self_pids() {
|
|
|
16
|
+ let pid = pid_tuple.0;
|
|
|
17
|
+ let ppid = pid_tuple.1;
|
|
|
18
|
+
|
|
|
19
|
+ // Commands & Threads for PID
|
|
|
20
|
+ if let Ok(pid_command) = readproc::get_pid_command(pid){
|
|
|
21
|
+ if let Ok(pid_threads) = readproc::get_thread_count(pid){
|
|
|
22
|
+ println!("My PID : {} - {} running {} threads", pid, pid_command, pid_threads);
|
|
|
23
|
+ }
|
|
31
|
24
|
}
|
|
32
|
|
- Err(_) => {}
|
|
|
25
|
+
|
|
|
26
|
+ // Commands & Threads for Parent-PID
|
|
|
27
|
+ if let Ok(ppid_command) = readproc::get_pid_command(ppid){
|
|
|
28
|
+ if let Ok(ppid_threads) = readproc::get_thread_count(ppid){
|
|
|
29
|
+ println!("My PPID: {} - {} running {} threads", ppid, ppid_command, ppid_threads);
|
|
|
30
|
+ }
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
33
|
33
|
}
|
|
34
|
34
|
|
|
35
|
35
|
|
|
36
|
|
- match readproc::get_ownprocess_mem() {
|
|
37
|
|
- Ok(size_tuple) => {
|
|
38
|
|
- // Memory
|
|
39
|
|
- let vspace = size_tuple.0;
|
|
40
|
|
- let code = size_tuple.1;
|
|
41
|
|
- let data = size_tuple.2;
|
|
|
36
|
+ if let Ok(size_tuple) = readproc::get_ownprocess_mem() {
|
|
|
37
|
+ // Memory
|
|
|
38
|
+ let vspace = size_tuple.0;
|
|
|
39
|
+ let code = size_tuple.1;
|
|
|
40
|
+ let data = size_tuple.2;
|
|
42
|
41
|
|
|
43
|
|
- println!("My mem : {} (vspace), {} (code), {} (data)", vspace, code, data);
|
|
44
|
|
- }
|
|
45
|
|
- Err(_) => {}
|
|
|
42
|
+ println!("My mem : {} (vspace), {} (code), {} (data)", vspace, code, data);
|
|
46
|
43
|
}
|
|
47
|
44
|
|
|
48
|
|
- match readproc::get_last_created_command() {
|
|
49
|
|
- Ok(last_command) => {
|
|
50
|
|
- // Last Process
|
|
51
|
|
- println!("Last process created in system was: {}", last_command);
|
|
52
|
|
- }
|
|
53
|
|
- Err(_) => {}
|
|
|
45
|
+ if let Ok(last_command) = readproc::get_last_created_command() {
|
|
|
46
|
+ // Last Process
|
|
|
47
|
+ println!("Last process created in system was: {}", last_command);
|
|
54
|
48
|
}
|
|
55
|
49
|
|
|
56
|
50
|
|
|
57
|
|
- match readproc::get_task_total() {
|
|
58
|
|
- Ok(task_total) => {
|
|
59
|
|
- // Number of tasks
|
|
60
|
|
- println!("Total number of tasks: {}", task_total);
|
|
61
|
|
- }
|
|
62
|
|
- Err(_) => {}
|
|
|
51
|
+ if let Ok(task_total) = readproc::get_task_total() {
|
|
|
52
|
+ // Number of tasks
|
|
|
53
|
+ println!("Total number of tasks: {}", task_total);
|
|
63
|
54
|
}
|
|
64
|
55
|
}
|
|
65
|
56
|
|
|
|
@@ -67,7 +58,6 @@ fn main() {
|
|
67
|
58
|
match args[1].parse::<i32>() {
|
|
68
|
59
|
Ok(pid) => {
|
|
69
|
60
|
if !pstree::print(pid) {
|
|
70
|
|
- println!("Invalid PID");
|
|
71
|
61
|
process::exit(1);
|
|
72
|
62
|
}
|
|
73
|
63
|
}
|