...

Source file src/github.com/opencontainers/runc/libcontainer/cgroups/getallpids.go

Documentation: github.com/opencontainers/runc/libcontainer/cgroups

     1  package cgroups
     2  
     3  import (
     4  	"io/fs"
     5  	"path/filepath"
     6  )
     7  
     8  // GetAllPids returns all pids from the cgroup identified by path, and all its
     9  // sub-cgroups.
    10  func GetAllPids(path string) ([]int, error) {
    11  	var pids []int
    12  	err := filepath.WalkDir(path, func(p string, d fs.DirEntry, iErr error) error {
    13  		if iErr != nil {
    14  			return iErr
    15  		}
    16  		if !d.IsDir() {
    17  			return nil
    18  		}
    19  		cPids, err := readProcsFile(p)
    20  		if err != nil {
    21  			return err
    22  		}
    23  		pids = append(pids, cPids...)
    24  		return nil
    25  	})
    26  	return pids, err
    27  }
    28  

View as plain text