Documentation ¶
Overview ¶
Package cgroup implements a thin wrapper around the Linux cgroupv2 filesystem API. For more information, please consult the relevant kernel documentation.
Index ¶
- func Move(pid int, into Dir) error
- type Dir
- func (d Dir) Create(sub string, kill bool) (Dir, error)
- func (d Dir) IsDelegated(uid, gid int) (bool, error)
- func (d Dir) IsZero() bool
- func (d Dir) Kill() error
- func (d Dir) Procs() ([]int, error)
- func (d Dir) Remove() error
- func (d Dir) Sub(dir string) Dir
- func (d Dir) WriteInt(name string, val int) error
- func (d Dir) WriteLine(name string, buf []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dir ¶
type Dir string
Dir is an absolute directory path (including the mount path of the cgroup2 mountpoint).
func Self ¶
Self returns the cgroup of the current process, provided that the current process is *only* a member of a cgroup2 and not a legacy cgroup1 hierarchy.
func (Dir) Create ¶
Create creates a new directory sub under the existing group d. If the directory doesn't already exist, it is created. If the directory *does* exist, then the behavior of Create depends on the 'kill' flag: if kill is set to true, then all the sub-processes in the existing cgroup are killed. If kill is set to false, then an error is returned (matching fs.ErrExist) and the cgroup is left unmodified.
func (Dir) IsDelegated ¶
IsDelegated returns (true, nil) if a process with the given uid+gid can add processes to d, or (false, nil) otherwise. IsDelegated will report an error if the cgroup doesn't exist.
func (Dir) IsZero ¶
IsZero returns true if d is the zero value of Dir. (The zero value of Dir is not a valid cgroup directory.)
func (Dir) Kill ¶
Kill kills all the processes in a cgroup. However, it does not remove the cgroup directory.
func (Dir) Procs ¶
Procs returns the list of pids that currently occupy a cgroup. (This corresponds to the cgroup.procs file within the cgroup directory.)
func (Dir) Remove ¶
Remove removes the cgroup. Only empty cgroups may be removed, so the caller may need to call Kill first in order to ensure the cgroup is empty.