fix lxc-ps to work with systemd

Dear all,
while working with systemd I found that lxc-ps -efa does not recognize the 
container name.
Best regards Joerg

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Joerg Gollnick 2011-07-25 00:22:50 +02:00 committed by Daniel Lezcano
parent bcbd102cba
commit c011782c8d

View File

@ -112,13 +112,18 @@ sub get_container {
my $pid = shift; my $pid = shift;
my $filename = "/proc/$pid/cgroup"; my $filename = "/proc/$pid/cgroup";
open(LXC, "$filename"); open(LXC, "$filename");
my $container = <LXC>; # read all lines at once
my @cgroup = <LXC>;
close LXC; close LXC;
chomp($container); my $container = '';
if ($container =~ m/[:,]ns[:,]/o) { foreach ( @cgroup ) {
$container =~ s/.*:\///o; chomp;
} else { # find the container name
$container =''; if (m/[:,]ns[:,]/o) {
# container name after :/
s/.*:\///o;
$container = $_;
}
} }
return $container; return $container;
} }