cgroups

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

* Copyright 2025 The Kubernetes Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	PIDSelf int = 0

	MaxValue string = "max"
)

Variables

View Source
var (
	MountPoint = "/sys/fs/cgroup"
)
View Source
var (
	// TestMode is set to true by unit tests that need "fake" cgroupfs.
	TestMode bool
)

Functions

func FullPathByPID

func FullPathByPID(procRoot string, pid int) (string, error)

func OpenFile

func OpenFile(lh logr.Logger, dir, file string, flags int) (*os.File, error)

OpenFile opens a cgroup file in a given dir with given flags. It is supposed to be used for cgroup files only, and returns an error if the file is not a cgroup file.

Arguments dir and file are joined together to form an absolute path to a file being opened.

func PIDToString

func PIDToString(pid int) (string, error)

func ParseValue

func ParseValue(lh logr.Logger, dir, file string) (int64, error)

func PathByPID

func PathByPID(procRoot string, pid int) (string, error)

func ReadFile

func ReadFile(lh logr.Logger, dir, file string) (string, error)

ReadFile reads data from a cgroup file in dir. It is supposed to be used for cgroup files only.

func WriteFile

func WriteFile(lh logr.Logger, dir, file, data string) error

WriteFile writes data to a cgroup file in dir. It is supposed to be used for cgroup files only.

func WriteValue

func WriteValue(lh logr.Logger, dir, file string, val int64) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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