forked from rosa/hakurei
ext: wrap close_range syscall
This is useful for container when called with CLOSE_RANGE_CLOEXEC. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -7,6 +7,26 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// include/uapi/linux/close_range.h
|
||||
const (
|
||||
CLOSE_RANGE_UNSHARE = 1 << (iota + 1)
|
||||
CLOSE_RANGE_CLOEXEC
|
||||
)
|
||||
|
||||
// CloseRange close all file descriptors in a given range.
|
||||
func CloseRange(first, last Uint, flags Int) error {
|
||||
_, _, errno := syscall.Syscall(
|
||||
SYS_CLOSE_RANGE,
|
||||
uintptr(first),
|
||||
uintptr(last),
|
||||
uintptr(flags),
|
||||
)
|
||||
if errno != 0 {
|
||||
return errno
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SchedPolicy denotes a scheduling policy defined in include/uapi/linux/sched.h.
|
||||
type SchedPolicy int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user