Skip to content

Commit 05e62d3

Browse files
committed
scxtop: adding uid to the process list.
Signed-off-by: David Carlier <[email protected]>
1 parent e59f253 commit 05e62d3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tools/scxtop/src/app.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,10 +2212,12 @@ impl<'a> App<'a> {
22122212
fn create_process_columns() -> Vec<Column> {
22132213
vec![
22142214
Column {
2215-
header: "TGID",
2215+
header: "TGID/UID",
22162216
constraint: Constraint::Length(8),
22172217
visible: true,
2218-
value_fn: Box::new(|tgid, _| tgid.to_string()),
2218+
value_fn: Box::new(|tgid, data| {
2219+
format!("{}/{}", tgid.to_string(), data.uid.to_string())
2220+
}),
22192221
},
22202222
Column {
22212223
header: "Name",
@@ -2325,6 +2327,7 @@ impl<'a> App<'a> {
23252327
.partial_cmp(&a.1.cpu_util_perc)
23262328
.unwrap_or(std::cmp::Ordering::Equal)
23272329
.then_with(|| b.1.threads.len().cmp(&a.1.threads.len()))
2330+
.then_with(|| b.1.uid.cmp(&a.1.uid))
23282331
});
23292332

23302333
let rows = sorted_view.into_iter().map(|(i, data)| {

tools/scxtop/src/proc_data.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::collections::BTreeMap;
1414
#[derive(Clone, Debug)]
1515
pub struct ProcData {
1616
pub tgid: i32,
17+
pub uid: u32,
1718
pub process_name: String,
1819
pub cpu: i32,
1920
pub llc: Option<u32>,
@@ -48,6 +49,7 @@ impl ProcData {
4849

4950
let proc_data = Self {
5051
tgid: process.pid,
52+
uid: process.uid().unwrap(),
5153
process_name: std::mem::take(&mut proc_stats.comm),
5254
cpu,
5355
llc: None,

0 commit comments

Comments
 (0)