sys

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// OOMScoreAdjMin is from OOM_SCORE_ADJ_MIN https://github.com/torvalds/linux/blob/v5.10/include/uapi/linux/oom.h#L9
	OOMScoreAdjMin = -1000
	// OOMScoreAdjMax is from OOM_SCORE_ADJ_MAX https://github.com/torvalds/linux/blob/v5.10/include/uapi/linux/oom.h#L10
	OOMScoreAdjMax = 1000
)

Variables

This section is empty.

Functions

func AdjustOOMScore

func AdjustOOMScore(pid, score int) error

AdjustOOMScore sets the oom score for the provided pid. If the provided score is out of range (-1000 - 1000), it is clipped to the min/max value.

func CreateUnixSocket

func CreateUnixSocket(path string) (net.Listener, error)

CreateUnixSocket creates a unix socket and returns the listener

func GetLocalListener

func GetLocalListener(path string, uid, gid int) (net.Listener, error)

GetLocalListener returns a listener out of a unix socket.

func GetOOMScoreAdj

func GetOOMScoreAdj(pid int) (int, error)

GetOOMScoreAdj gets the oom score for a process. It returns 0 (zero) if either no oom score is set, or a sore is set to 0.

func GetUsernsForNamespace

func GetUsernsForNamespace(fd uintptr) (*os.File, error)

GetUsernsForNamespace returns a file descriptor that refers to the owning user namespace for the namespace referred to by fd.

REF: https://man7.org/linux/man-pages/man2/ioctl_ns.2.html

func IgnoringEINTR

func IgnoringEINTR(fn func() error) error

IgnoringEINTR makes a function call and repeats it if it returns an EINTR error. This appears to be required even though we install all signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846. Also #20400 and #36644 are issues in which a signal handler is installed without setting SA_RESTART. None of these are the common case, but there are enough of them that it seems that we can't avoid an EINTR loop.

func MkdirAllWithACL

func MkdirAllWithACL(path string, perm os.FileMode) error

MkdirAllWithACL is a wrapper for os.MkdirAll on Unix systems.

func SetOOMScore

func SetOOMScore(pid, score int) error

SetOOMScore sets the oom score for the provided pid

func SupportsPidFD

func SupportsPidFD() bool

SupportsPidFD returns true if current kernel supports pidfd.

func UnshareAfterEnterUserns

func UnshareAfterEnterUserns(uidMap, gidMap string, unshareFlags uintptr, f func(pid int) error) (retErr error)

UnshareAfterEnterUserns allows to disassociate parts of its execution context within a user namespace.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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