rlimit_keys.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //go:build !windows && !plan9 && !js
  2. package unix
  3. import "golang.org/x/sys/unix"
  4. var rlimitKeys = map[int]string{
  5. // The following are defined by POSIX
  6. // (https://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html).
  7. //
  8. // Note: RLIMIT_AS is defined by POSIX, but missing on OpenBSD
  9. // (https://man.openbsd.org/getrlimit.2#BUGS); it is defined on Darwin, but
  10. // it's an undocumented alias of RLIMIT_RSS there.
  11. unix.RLIMIT_CORE: "core",
  12. unix.RLIMIT_CPU: "cpu",
  13. unix.RLIMIT_DATA: "data",
  14. unix.RLIMIT_FSIZE: "fsize",
  15. unix.RLIMIT_NOFILE: "nofile",
  16. unix.RLIMIT_STACK: "stack",
  17. // The following are not defined by POSIX, but supported by every UNIX OS
  18. // Elvish supports (Linux, macOS, Free/Net/OpenBSD). See:
  19. //
  20. // - https://man7.org/linux/man-pages/man2/setrlimit.2.html
  21. // - https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getrlimit.2.html
  22. // - https://www.freebsd.org/cgi/man.cgi?query=getrlimit
  23. // - https://man.netbsd.org/getrlimit.2
  24. // - https://man.openbsd.org/getrlimit.2
  25. unix.RLIMIT_MEMLOCK: "memlock",
  26. unix.RLIMIT_NPROC: "nproc",
  27. unix.RLIMIT_RSS: "rss",
  28. }
  29. //lint:ignore U1000 used on some OS
  30. func addRlimitKeys(m map[int]string) {
  31. for k, v := range m {
  32. rlimitKeys[k] = v
  33. }
  34. }