Skip to content

Commit 146a9ad

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

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tools/scxtop/src/app.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,10 +2212,10 @@ 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| format!("{tgid}/{}", data.uid)),
22192219
},
22202220
Column {
22212221
header: "Name",
@@ -2325,6 +2325,7 @@ impl<'a> App<'a> {
23252325
.partial_cmp(&a.1.cpu_util_perc)
23262326
.unwrap_or(std::cmp::Ordering::Equal)
23272327
.then_with(|| b.1.threads.len().cmp(&a.1.threads.len()))
2328+
.then_with(|| b.1.uid.cmp(&a.1.uid))
23282329
});
23292330

23302331
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)