cgroup

package
v0.0.0-...-e70f483 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cgroup parses /proc cgroup membership data without cgroup filesystem access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CGroupIDFromEntries

func CGroupIDFromEntries(cgroups []ControlGroup) containerutils.CGroupID

CGroupIDFromEntries picks a cgroup path string suitable as CGroupID from parsed /proc cgroup lines.

func ContainerContextFromProcCgroupData

func ContainerContextFromProcCgroupData(data []byte) (containerutils.ContainerID, containerutils.CGroupID)

ContainerContextFromProcCgroupData returns container ID and cgroup path id from a single parse of the proc cgroup file.

func FindContainerIDFromEntries

func FindContainerIDFromEntries(cgroups []ControlGroup) containerutils.ContainerID

FindContainerIDFromEntries extracts a container ID from parsed /proc cgroup lines.

func ParseCgroupLine

func ParseCgroupLine(line string) (id, ctrl, path string, err error)

ParseCgroupLine parses a single line from /proc/[pid]/cgroup.

Types

type ControlGroup

type ControlGroup struct {
	// ID unique hierarchy ID
	ID int

	// Controllers are the list of cgroup controllers bound to the hierarchy
	Controllers []string

	// Path is the pathname of the control group to which the process
	// belongs. It is relative to the mountpoint of the hierarchy.
	Path string
}

ControlGroup describes the cgroup membership of a process (paths from /proc).

func MakeControlGroup

func MakeControlGroup(id, ctrl, path string) (ControlGroup, error)

MakeControlGroup builds a ControlGroup from fields returned by ParseCgroupLine.

func ParseProcCgroupDataLenient

func ParseProcCgroupDataLenient(data []byte) []ControlGroup

ParseProcCgroupDataLenient parses /proc/[pid]/cgroup: trims lines, skips empty lines, and skips lines that cannot be parsed or have a non-integer hierarchy id.

func ParseProcCgroupDataStrict

func ParseProcCgroupDataStrict(data []byte) ([]ControlGroup, error)

ParseProcCgroupDataStrict parses the full /proc/[pid]/cgroup file; any non-empty invalid line is an error.

func (ControlGroup) GetContainerContext

func (cg ControlGroup) GetContainerContext() containerutils.ContainerID

GetContainerContext returns the container ID derived from the cgroup path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL