Skip to content
Permalink
Browse files

Fix the value corresponding to rlimitmap [key]

These values depend on the specific arch

Signed-off-by: wanghuaiqing <wanghuaiqing@loongson.cn>
  • Loading branch information
wanghuaiqing
wanghuaiqing committed Feb 7, 2020
1 parent e6555cc commit f27c4e15f696842340f217658f55f836854169ce
Showing with 17 additions and 35 deletions.
  1. +17 −35 rlimit_linux.go
@@ -1,43 +1,25 @@
package main

import "fmt"

const (
RLIMIT_CPU = iota // CPU time in sec
RLIMIT_FSIZE // Maximum filesize
RLIMIT_DATA // max data size
RLIMIT_STACK // max stack size
RLIMIT_CORE // max core file size
RLIMIT_RSS // max resident set size
RLIMIT_NPROC // max number of processes
RLIMIT_NOFILE // max number of open files
RLIMIT_MEMLOCK // max locked-in-memory address space
RLIMIT_AS // address space limit
RLIMIT_LOCKS // maximum file locks held
RLIMIT_SIGPENDING // max number of pending signals
RLIMIT_MSGQUEUE // maximum bytes in POSIX mqueues
RLIMIT_NICE // max nice prio allowed to raise to
RLIMIT_RTPRIO // maximum realtime priority
RLIMIT_RTTIME // timeout for RT tasks in us
)
import "golang.org/x/sys/unix"

var rlimitMap = map[string]int{
"RLIMIT_CPU": RLIMIT_CPU,
"RLIMIT_FSIZE": RLIMIT_FSIZE,
"RLIMIT_DATA": RLIMIT_DATA,
"RLIMIT_STACK": RLIMIT_STACK,
"RLIMIT_CORE": RLIMIT_CORE,
"RLIMIT_RSS": RLIMIT_RSS,
"RLIMIT_NPROC": RLIMIT_NPROC,
"RLIMIT_NOFILE": RLIMIT_NOFILE,
"RLIMIT_MEMLOCK": RLIMIT_MEMLOCK,
"RLIMIT_AS": RLIMIT_AS,
"RLIMIT_LOCKS": RLIMIT_LOCKS,
"RLIMIT_SIGPENDING": RLIMIT_SIGPENDING,
"RLIMIT_MSGQUEUE": RLIMIT_MSGQUEUE,
"RLIMIT_NICE": RLIMIT_NICE,
"RLIMIT_RTPRIO": RLIMIT_RTPRIO,
"RLIMIT_RTTIME": RLIMIT_RTTIME,
"RLIMIT_CPU": unix.RLIMIT_CPU,
"RLIMIT_FSIZE": unix.RLIMIT_FSIZE,
"RLIMIT_DATA": unix.RLIMIT_DATA,
"RLIMIT_STACK": unix.RLIMIT_STACK,
"RLIMIT_CORE": unix.RLIMIT_CORE,
"RLIMIT_RSS": unix.RLIMIT_RSS,
"RLIMIT_NPROC": unix.RLIMIT_NPROC,
"RLIMIT_NOFILE": unix.RLIMIT_NOFILE,
"RLIMIT_MEMLOCK": unix.RLIMIT_MEMLOCK,
"RLIMIT_AS": unix.RLIMIT_AS,
"RLIMIT_LOCKS": unix.RLIMIT_LOCKS,
"RLIMIT_SIGPENDING": unix.RLIMIT_SIGPENDING,
"RLIMIT_MSGQUEUE": unix.RLIMIT_MSGQUEUE,
"RLIMIT_NICE": unix.RLIMIT_NICE,
"RLIMIT_RTPRIO": unix.RLIMIT_RTPRIO,
"RLIMIT_RTTIME": unix.RLIMIT_RTTIME,
}

func strToRlimit(key string) (int, error) {

0 comments on commit f27c4e1

Please sign in to comment.
You can’t perform that action at this time.