mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
a75076b4a4
This removes libcontainer/cgroups packages and starts
using those from github.com/opencontainers/cgroups repo.
Mostly generated by:
git rm -f libcontainer/cgroups
find . -type f -name "*.go" -exec sed -i \
's|github.com/opencontainers/runc/libcontainer/cgroups|github.com/opencontainers/cgroups|g' \
{} +
go get github.com/opencontainers/cgroups@v0.0.1
make vendor
gofumpt -w .
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
28 lines
505 B
Go
28 lines
505 B
Go
package cgroups
|
|
|
|
import (
|
|
"io/fs"
|
|
"path/filepath"
|
|
)
|
|
|
|
// GetAllPids returns all pids from the cgroup identified by path, and all its
|
|
// sub-cgroups.
|
|
func GetAllPids(path string) ([]int, error) {
|
|
var pids []int
|
|
err := filepath.WalkDir(path, func(p string, d fs.DirEntry, iErr error) error {
|
|
if iErr != nil {
|
|
return iErr
|
|
}
|
|
if !d.IsDir() {
|
|
return nil
|
|
}
|
|
cPids, err := readProcsFile(p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pids = append(pids, cPids...)
|
|
return nil
|
|
})
|
|
return pids, err
|
|
}
|