Skip to content

Commit b4f1066

Browse files
Fix no names appearing for some commands in psq
1 parent 9026b39 commit b4f1066

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/psq/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::collections::HashMap;
88
use std::iter::repeat;
99
use procrs::pid::*;
1010
use procrs::TaskId;
11+
use procrs::meminfo::MeminfoStatus;
1112
use argparse::{ArgumentParser, StoreTrue, Store};
1213

1314
fn main() {
@@ -46,15 +47,25 @@ fn main() {
4647
row![p.stat.pid, p.stat.ppid, name]
4748
},
4849
(true, false) => {
49-
name.push_str(&p.cmdline.join(" "));
50+
name.push_str(
51+
match p.cmdline.join(" ") {
52+
ref s if s.len() > 0 => s,
53+
_ => &p.stat.comm
54+
}
55+
);
5056
row![p.stat.pid, p.stat.ppid, name]
5157
},
5258
(false, true) => {
5359
name.push_str(&p.stat.comm);
5460
row![p.stat.pid, p.stat.ppid, name]
5561
}
5662
(true, true) => {
57-
name.push_str(&p.cmdline.join(" "));
63+
name.push_str(
64+
match p.cmdline.join(" ") {
65+
ref s if s.len() > 0 => s,
66+
_ => &p.stat.comm
67+
}
68+
);
5869
row![p.stat.pid, p.stat.ppid, name]
5970
}
6071
}

0 commit comments

Comments
 (0)