summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMantas Mikulėnas <grawity@gmail.com>2012-10-19 20:15:25 +0300
committerLennart Poettering <lennart@poettering.net>2012-10-23 17:13:20 +0200
commit4278aa278cf05158c874cf9f28f45a1f60413ee6 (patch)
treeb90483bd0253fdbd0117bdeee0e479042e9c8435 /src
parentef421e4d55354148f1f1410cb50d1c0e734b90bd (diff)
cgls: correctly ellipsize command lines for PIDs >= 1000000
Diffstat (limited to 'src')
-rw-r--r--src/shared/cgroup-show.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 9003a1228e..2ffed8b739 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -52,7 +52,7 @@ static unsigned ilog10(unsigned long ul) {
}
static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsigned n_columns, bool extra, bool more, bool kernel_threads) {
- unsigned i, m;
+ unsigned i, m, pid_width;
pid_t biggest = 0;
/* Filter duplicates */
@@ -71,12 +71,13 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi
pids[m++] = pids[i];
}
n_pids = m;
+ pid_width = ilog10(biggest);
/* And sort */
qsort(pids, n_pids, sizeof(pid_t), compare);
- if (n_columns > 8)
- n_columns -= 8;
+ if (n_columns > pid_width+2)
+ n_columns -= pid_width+2;
else
n_columns = 20;
@@ -88,7 +89,7 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi
printf("%s%s %*lu %s\n",
prefix,
extra ? "\342\200\243" : ((more || i < n_pids-1) ? "\342\224\234" : "\342\224\224"),
- (int) ilog10(biggest),
+ pid_width,
(unsigned long) pids[i],
strna(t));