Bug 56644 - systemd-cgls shows 'n/a' for when piping output less or more
Summary: systemd-cgls shows 'n/a' for when piping output less or more
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-01 17:00 UTC by Shawn Starr
Modified: 2012-11-19 16:17 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch to handle failed columns detection. (342 bytes, patch)
2012-11-08 13:11 UTC, Anders Olofsson
Details | Splinter Review

Description Shawn Starr 2012-11-01 17:00:30 UTC
Output

$ systemd-cgls | less

 user
│ └ foo
│   └ 2
│     ├  1170 n/a
│     ├  1178 n/a
│     ├  1187 n/a
│     ├  1188 n/a
│     ├  1193 n/a
│     ├  1241 n/a
│     ├  1242 n/a
│     ├  1243 n/a
│     ├  1245 n/a
│     ├  1247 n/a
│     ├  1251 n/a
│     ├  1253 n/a

Output:

$ systemd-cgls | less

├ user
│ └ foo
│   └ 2
│     ├  1170 gdm-session-worker [pam/gdm-password]
│     ├  1178 /bin/sh /usr/bin/startkde
│     ├  1187 dbus-launch --sh-syntax --exit-with-session
│     ├  1188 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
│     ├  1193 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "/usr/bin/startkde"


Seems like a bug?
Comment 1 Thomas H.P. Andersen 2012-11-02 18:55:38 UTC
What version is this? I tried to reproduce the problem on 195 (latest in f18) but I cannot. I do not see the n/a with any of "systemd-cgls", "systemd-cgls | less", or "systemd-cgls | more".

Both your examples use "$ systemd-cgls | less". I assume one of them should have been different?
Comment 2 Shawn Starr 2012-11-02 19:06:56 UTC
systemd-libs-195-2.fc18.x86_64
systemd-sysv-195-2.fc18.x86_64
systemd-libs-195-2.fc18.i686
systemd-195-2.fc18.x86_64

195

Yes, w/o less it will show properly

so:


$ systemd-cgls 

├ user
│ └ foo
│   └ 2
│     ├ 1176 gdm-session-worker [pam/gdm-password]
│     ├ 1183 /bin/sh /usr/bin/startkde
│     ├ 1192 dbus-launch --sh-syntax --exit-with-session

$  systemd-cgls | less

├ user
│ └ foo
│   └ 2
│     ├ 1176 n/a
│     ├ 1183 n/a
│     ├ 1192 n/a


Some more information. which may or may not be relevant 

I am using Huge Pages

my sysctl.d config:  107 = qemu group

# Test - Use HugePageTables
vm.nr_hugepages = 512
vm.hugetlb_shm_group = 107

# Kernel tweaks
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.shmall = 1048576

cgroup mounts:

$ mount | grep cgroup
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
Comment 3 Anders Olofsson 2012-11-08 13:11:17 UTC
Created attachment 69696 [details] [review]
Patch to handle failed columns detection.

This looks like the same problem I'm having. I have attached a patch that solves it for me.

The problem is that terminal width detection fails (fd_columns() in src/shared/util.c) but the calling function (columns() in src/shared/util.c) doesn't handle signed values and returns 4294967273 as the number of columns.
When the fault column number is passed along to get_process_cmdline() (in src/shared/util.c) it fails to allocate memory for a string that wide resulting in a null pointer that is printed as "n/a".

Fault exists in version 195 but not in 194.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.