1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#![crate_name = "sysinfo"]
#![crate_type = "lib"]
#![crate_type = "rlib"]
#![deny(missing_docs)]
#![allow(unknown_lints)]
#[macro_use]
extern crate cfg_if;
#[cfg(not(any(target_os = "unknown", target_arch = "wasm32")))]
extern crate libc;
extern crate rayon;
#[macro_use]
extern crate doc_comment;
#[cfg(test)]
doctest!("../README.md");
cfg_if! {
if #[cfg(target_os = "macos")] {
mod mac;
use mac as sys;
} else if #[cfg(windows)] {
mod windows;
use windows as sys;
extern crate winapi;
extern crate ntapi;
} else if #[cfg(unix)] {
mod linux;
use linux as sys;
} else {
mod unknown;
use unknown as sys;
}
}
pub use common::{AsU32, Pid, RefreshKind};
pub use sys::{Component, Disk, DiskType, NetworkData, Process, ProcessStatus, Processor, System};
pub use traits::{ComponentExt, DiskExt, NetworkExt, ProcessExt, ProcessorExt, SystemExt};
#[cfg(feature = "c-interface")]
pub use c_interface::*;
pub use utils::get_current_pid;
#[cfg(feature = "c-interface")]
mod c_interface;
mod common;
mod component;
mod process;
mod processor;
mod system;
mod traits;
mod utils;
#[repr(C)]
#[derive(Clone, PartialEq, PartialOrd, Debug, Copy)]
pub enum Signal {
Hangup = 1,
Interrupt = 2,
Quit = 3,
Illegal = 4,
Trap = 5,
Abort = 6,
Bus = 7,
FloatingPointException = 8,
Kill = 9,
User1 = 10,
Segv = 11,
User2 = 12,
Pipe = 13,
Alarm = 14,
Term = 15,
Stklft = 16,
Child = 17,
Continue = 18,
Stop = 19,
TSTP = 20,
TTIN = 21,
TTOU = 22,
Urgent = 23,
XCPU = 24,
XFSZ = 25,
VirtualAlarm = 26,
Profiling = 27,
Winch = 28,
IO = 29,
Power = 30,
Sys = 31,
}
#[cfg(test)]
mod test {
use traits::{ProcessExt, SystemExt};
#[test]
fn check_memory_usage() {
let mut s = ::System::new();
s.refresh_all();
assert_eq!(
s.get_process_list()
.iter()
.all(|(_, proc_)| proc_.memory() == 0),
false
);
}
}