summaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/containerd/cgroups/utils.go
diff options
context:
space:
mode:
authorLantao Liu <lantaol@google.com>2019-05-10 18:27:49 -0700
committerIan Lewis <ianlewis@google.com>2019-05-11 10:27:49 +0900
commit97875daf63d03cda6ff3c4f393a004a8295a748e (patch)
tree30dce772c1d7bb9d77fab8b224675630e3c10b2d /vendor/github.com/containerd/cgroups/utils.go
parent14f1de4a45daa75ef016fabb56d86cbd9b902504 (diff)
Port shim fix (#27)
Port shim fixes containerd/containerd#3264, containerd/containerd#3264 Update containerd to newest release/1.2 commit.
Diffstat (limited to 'vendor/github.com/containerd/cgroups/utils.go')
-rw-r--r--vendor/github.com/containerd/cgroups/utils.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/vendor/github.com/containerd/cgroups/utils.go b/vendor/github.com/containerd/cgroups/utils.go
index 345be4e46..f3129b1a3 100644
--- a/vendor/github.com/containerd/cgroups/utils.go
+++ b/vendor/github.com/containerd/cgroups/utils.go
@@ -111,7 +111,7 @@ func remove(path string) error {
return fmt.Errorf("cgroups: unable to remove path %q", path)
}
-// readPids will read all the pids in a cgroup by the provided path
+// readPids will read all the pids of processes in a cgroup by the provided path
func readPids(path string, subsystem Name) ([]Process, error) {
f, err := os.Open(filepath.Join(path, cgroupProcs))
if err != nil {
@@ -138,6 +138,33 @@ func readPids(path string, subsystem Name) ([]Process, error) {
return out, nil
}
+// readTasksPids will read all the pids of tasks in a cgroup by the provided path
+func readTasksPids(path string, subsystem Name) ([]Task, error) {
+ f, err := os.Open(filepath.Join(path, cgroupTasks))
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ var (
+ out []Task
+ s = bufio.NewScanner(f)
+ )
+ for s.Scan() {
+ if t := s.Text(); t != "" {
+ pid, err := strconv.Atoi(t)
+ if err != nil {
+ return nil, err
+ }
+ out = append(out, Task{
+ Pid: pid,
+ Subsystem: subsystem,
+ Path: path,
+ })
+ }
+ }
+ return out, nil
+}
+
func hugePageSizes() ([]string, error) {
var (
pageSizes []string