Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ process-data = { path = "lib/process_data" }
rmp-serde = "1.3.1"
ron = "0.12.0"
rust-ini = "0.21.3"
futures = { version = "0.3", default-features = false, features = ["alloc"] }
serde_json = "1.0.149"
soup3 = "0.8.0"
strum = "0.28.0"
strum_macros = "0.28.0"
sysconf = "0.3.4"
Expand Down
28 changes: 27 additions & 1 deletion lib/process_data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ static RE_CGROUP: Lazy<Regex> = lazy_regex!(
r"(?U)/(?:app|background)\.slice/(?:app-|dbus-:)(?:(?P<launcher>[^-]+)-)?(?P<cgroup>[^-]+)(?:-[0-9]+|@[0-9]+)?\.(?:scope|service)"
);

/* The cgroup of a snap process is composed of: `snap.<snap-name>.<app-name>-<uuid>.scope`
* The name has the following restrictions:
* > It must start with an ASCII character and can only contain lower case letters, numbers, and hyphens.
* > It must contain at least one letter and it can’t start or end with a hyphen.
* https://documentation.ubuntu.com/snapcraft/8.9.4/reference/project-file/snapcraft-yaml/#name
*
* Furthermore, the snap name may contain a single '_' character that denotes a specific instance of this snap.
* https://snapcraft.io/docs/explanation/how-snaps-work/parallel-installs/#installing-multiple-instances
*
* Because '-' is both the separator character before the uuid as well as a valid character for the names,
* we must try to match the start of the uuid group exactly.
*/
static RE_SNAP_CGROUP: Lazy<Regex> = lazy_regex!(
r"/snap\.(?P<cgroup>[_\-0-9a-z]+\.[\-0-9a-z]+)(?:-[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})\.(?:scope|service)"
);

static RE_AFFINITY: Lazy<Regex> = lazy_regex!(r"Cpus_allowed:\s*([0-9A-Fa-f]+)");

static RE_MEMORY_USAGE: Lazy<Regex> = lazy_regex!(r"VmRSS:\s*([0-9]+)\s*kB");
Expand Down Expand Up @@ -270,6 +286,16 @@ impl ProcessData {
.and_then(|s| Self::decode_hex_escapes(s.as_str()).ok()),
)
})
.or_else(|| {
RE_SNAP_CGROUP.captures(cgroup.as_ref()).map(|captures| {
(
Some("snap".to_string()),
captures
.name("cgroup")
.and_then(|s| Self::decode_hex_escapes(s.as_str()).ok()),
)
})
})
.unwrap_or_default()
}

Expand Down Expand Up @@ -459,7 +485,7 @@ impl ProcessData {

let appimage_path = environ.get("APPIMAGE").map(std::borrow::ToOwned::to_owned);

let containerization = if commandline.starts_with("/snap/") {
let containerization = if commandline.starts_with("/snap/") || launcher == "snap" {
Containerization::Snap
} else if proc_path
.join("root")
Expand Down
2 changes: 2 additions & 0 deletions src/ui/pages/processes/process_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ impl ProcessEntry {
pub fn update(&self, process: &Process) {
trace!("Refreshing ProcessEntry ({})…", process.data.pid);

self.set_icon(&process.icon);

self.set_cpu_usage(process.cpu_time_ratio());
self.set_memory_usage(process.data.memory_usage as u64);
self.set_swap_usage(process.data.swap_usage as u64);
Expand Down
Loading
Loading