Documentation ¶
Index ¶
- Constants
- func AdjustOOMScore(pid, score int) error
- func CreateUnixSocket(path string) (net.Listener, error)
- func ForkUserns() (_pid uintptr, _pidfd uintptr, _ syscall.Errno)
- func GetLocalListener(path string, uid, gid int) (net.Listener, error)
- func GetOOMScoreAdj(pid int) (int, error)
- func IgnoringEINTR(fn func() error) error
- func MkdirAllWithACL(path string, perm os.FileMode) error
- func SetOOMScore(pid, score int) error
Constants ¶
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 ¶
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 ¶
CreateUnixSocket creates a unix socket and returns the listener
func ForkUserns ¶
ForkUserns is to fork child process with user namespace. It returns child process's pid and pidfd reference to the child process.
Precondition: The runtime OS thread must be locked, which is GO runtime requirement.
Beside this, the child process sets PR_SET_PDEATHSIG with SIGKILL so that the parent process's OS thread must be locked. Otherwise, the exit event of parent process's OS thread will send kill signal to the child process, even if parent process is still running.
func GetLocalListener ¶
GetLocalListener returns a listener out of a unix socket.
func GetOOMScoreAdj ¶
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 IgnoringEINTR ¶
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 ¶
MkdirAllWithACL is a wrapper for os.MkdirAll on Unix systems.
func SetOOMScore ¶
SetOOMScore sets the oom score for the provided pid
Types ¶
This section is empty.