summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-10-28 02:50:47 +0000
committergVisor bot <gvisor-bot@google.com>2020-10-28 02:50:47 +0000
commit0a7d2ef5a792a2bd01de75c9ed59c99d4872ff0a (patch)
tree7fd9465f907a7a332f0ec49dac81c3d1a6c169fc /runsc
parent6b463fe2b71a6201db0abd052d964c59317e6f6e (diff)
parent93d2d37a93640328f01add7d4866bc107ff6a74e (diff)
Merge release-20201019.0-77-g93d2d37a9 (automated)
Diffstat (limited to 'runsc')
-rw-r--r--runsc/cgroup/cgroup.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/runsc/cgroup/cgroup.go b/runsc/cgroup/cgroup.go
index 56da21584..5bd0afc52 100644
--- a/runsc/cgroup/cgroup.go
+++ b/runsc/cgroup/cgroup.go
@@ -21,6 +21,7 @@ import (
"context"
"errors"
"fmt"
+ "io"
"io/ioutil"
"os"
"path/filepath"
@@ -198,8 +199,13 @@ func LoadPaths(pid string) (map[string]string, error) {
}
defer f.Close()
+ return loadPathsHelper(f)
+}
+
+func loadPathsHelper(cgroup io.Reader) (map[string]string, error) {
paths := make(map[string]string)
- scanner := bufio.NewScanner(f)
+
+ scanner := bufio.NewScanner(cgroup)
for scanner.Scan() {
// Format: ID:[name=]controller1,controller2:path
// Example: 2:cpu,cpuacct:/user.slice
@@ -207,6 +213,9 @@ func LoadPaths(pid string) (map[string]string, error) {
if len(tokens) != 3 {
return nil, fmt.Errorf("invalid cgroups file, line: %q", scanner.Text())
}
+ if len(tokens[1]) == 0 {
+ continue
+ }
for _, ctrlr := range strings.Split(tokens[1], ",") {
// Remove prefix for cgroups with no controller, eg. systemd.
ctrlr = strings.TrimPrefix(ctrlr, "name=")