Skip to content

Commit

Permalink
check if process is system
Browse files Browse the repository at this point in the history
  • Loading branch information
errorxyz committed Dec 19, 2024
1 parent 69bc397 commit f3773dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/processes/linux_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ pub fn active_executables() -> Result<ProcessList> {
let executable = e.key().clone();
// .file_name() returns `None` if the path terminates in `..`
// We use the absolute path in such a case.
let display_name = match path.file_name() {
Some(s) => s.to_string_lossy().to_string(),
None => path.to_string_lossy().to_string(),
let display_name = path
.file_name()
.unwrap_or(path.as_os_str())
.to_string_lossy()
.to_string();
let is_system = match process.effective_user_id() {
Some(id) => id.to_string() == "0",
None => false,
};
e.insert(ProcessInfo {
executable,
display_name,
is_visible: false,
is_system: false,
is_system,
});
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/processes/macos_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ pub fn active_executables() -> Result<ProcessList> {
let executable = e.key().clone();
// .file_name() returns `None` if the path terminates in `..`
// We use the absolute path in such a case.
let display_name = match path.file_name() {
Some(s) => s.to_string_lossy().to_string(),
None => path.to_string_lossy().to_string(),
let display_name = path
.file_name()
.unwrap_or(path.as_os_str())
.to_string_lossy()
.to_string();
let is_system = match process.effective_user_id() {
Some(id) => id.to_string() == "0",
None => false,
};
let is_visible = visible.contains(&pid);
let is_system = executable.starts_with("/System/");
e.insert(ProcessInfo {
executable,
display_name,
Expand Down

0 comments on commit f3773dc

Please sign in to comment.