|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+use procinfo::pid::Stat;
|
|
|
2
|
+use procinfo::pid;
|
|
|
3
|
+
|
|
|
4
|
+pub fn self_pids() -> Result<(i32, i32), &'static str>{
|
|
|
5
|
+ match pid::stat_self() {
|
|
|
6
|
+ Ok(stat) => { Ok((stat.pid, stat.ppid)) }
|
|
|
7
|
+ Err(_) => { Err("Fehler") }
|
|
|
8
|
+ }
|
|
|
9
|
+}
|
|
|
10
|
+
|
|
|
11
|
+pub fn get_pid_command(pid: i32) -> Result<String, &'static str> {
|
|
|
12
|
+ match pid::stat(pid) {
|
|
|
13
|
+ Ok(stat) => { Ok(stat.command) }
|
|
|
14
|
+ Err(_) => { Err("Fehler") }
|
|
|
15
|
+ }
|
|
|
16
|
+}
|
|
|
17
|
+
|
|
|
18
|
+pub fn get_last_created_command() -> Result<String, &'static str> {
|
|
|
19
|
+ match pid::stat_self() {
|
|
|
20
|
+ Ok(stat) => { Ok(stat.command) }
|
|
|
21
|
+ Err(_) => { Err("Fehler") }
|
|
|
22
|
+ }
|
|
|
23
|
+
|
|
|
24
|
+}
|
|
|
25
|
+
|
|
|
26
|
+pub fn get_thread_count(pid: i32) -> Result<u32, &'static str> {
|
|
|
27
|
+ match pid::stat(pid) {
|
|
|
28
|
+ Ok(stat) => { Ok(stat.num_threads as u32) }
|
|
|
29
|
+ Err(_) => { Err("Fehler") }
|
|
|
30
|
+ }
|
|
|
31
|
+}
|