Skip to content

Commit

Permalink
args truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
jacek-kurlit committed Feb 12, 2024
1 parent 39c6ac7 commit a76dbfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ impl ProcessQuery {
pid: stat.pid,
user_name,
total_time: Duration::from_secs_f32(total_time),
args: get_process_args(&prc, &stat.comm),
cmd: stat.comm,
state,
args: prc.cmdline().unwrap_or_default(),
});
}
}
Ok(result)
}
}

// NOTE: Some processes have path to binary as first argument, but also some processes has different name than cmd (for exmaple firefox)
fn get_process_args(prc: &procfs::process::Process, cmd: &str) -> Vec<String> {
let args = prc.cmdline().unwrap_or_default();
if args.first().is_some_and(|arg1| arg1.ends_with(cmd)) {
return args.into_iter().skip(1).collect();
}
args
}

pub struct Process {
pub pid: i32,
pub user_name: String,
Expand Down
1 change: 1 addition & 0 deletions src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ fn render_table(f: &mut Frame, app: &mut App, area: Rect) {
),
format!("\n{:?}\n", data.state),
format!("\n{}\n", data.cmd),
//FIXME: this should be somehow tructated because args may be really long
format!("\n{:?}\n", data.args),
])
.style(Style::new().fg(app.colors.row_fg).bg(color))
Expand Down

0 comments on commit a76dbfb

Please sign in to comment.