Commit 1af60b51 by Weng Meiling Committed by Serge Hallyn

lxc-ps: fix the display problem with arg --lxc

When we use arg --lxc to show processes in all containers, no process displays, so fix it. (Changelog: Serge: in-line fix of s/;;/;/ at line 69) Signed-off-by: 's avatarWeng Meiling <wengmeiling.weng@huawei.com> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent eddaaafd
...@@ -39,9 +39,10 @@ help() { ...@@ -39,9 +39,10 @@ help() {
get_parent_cgroup() get_parent_cgroup()
{ {
local hierarchies hierarchy fields subsystems init_cgroup mountpoint local hierarchies hierarchy fields init_cgroup mountpoint
parent_cgroup="" parent_cgroup=""
subsystems=""
# Obtain a list of hierarchies that contain one or more subsystems # Obtain a list of hierarchies that contain one or more subsystems
hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2) hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
...@@ -65,11 +66,7 @@ get_parent_cgroup() ...@@ -65,11 +66,7 @@ get_parent_cgroup()
if [ -z "$mountpoint" ]; then continue; fi if [ -z "$mountpoint" ]; then continue; fi
# Return the absolute path to the containers' parent cgroup # Return the absolute path to the containers' parent cgroup
# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem) parent_cgroup="${mountpoint}${init_cgroup%/}";
case ",$subsystems," in
*,ns,*) parent_cgroup="${mountpoint}${init_cgroup%/}";;
*) parent_cgroup="${mountpoint}${init_cgroup%/}";;
esac
break break
done done
} }
...@@ -106,7 +103,10 @@ if [ ! -d "$parent_cgroup" ]; then ...@@ -106,7 +103,10 @@ if [ ! -d "$parent_cgroup" ]; then
fi fi
if [ -z "$containers" ]; then if [ -z "$containers" ]; then
containers="$(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')" case ",$subsystems," in
*,ns,*) containers="$(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')";;
*) containers="$(find $parent_cgroup/lxc -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')";;
esac
fi fi
container_field_width=9 container_field_width=9
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment