src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/mods/unix/rlimit.d.elv (about) 1 # A map describing resource limits of the current process. 2 # 3 # Each key is a string corresponds to a resource, and each value is a map with 4 # keys `&cur` and `&max`, describing the soft and hard limits of that resource. 5 # A missing `&cur` key means that there is no soft limit; a missing `&max` key 6 # means that there is no hard limit. 7 # 8 # The following resources are supported, some only present on certain OSes: 9 # 10 # * `core`: size of a core file, in bytes. 11 # 12 # * `cpu`: CPU time, in seconds. 13 # 14 # * `data`: size of the data segment, in bytes 15 # 16 # * `fsize`: size of a file created by the process, in bytes. 17 # 18 # * `memlock`: size of locked memory, in bytes. 19 # 20 # * `nofile`: number of file descriptors. 21 # 22 # * `nproc`: number of processes for the user. 23 # 24 # * `rss`: resident set size, in bytes. 25 # 26 # * `stack`: size of the stack segment, in bytes. 27 # 28 # * `as`: size of the address space, in bytes. Available on Linux, FreeBSD and NetBSD. 29 # 30 # * `nthr`: number of threads for the user. NetNSD only. 31 # 32 # * `sbsize`: size of socket buffers, in bytes. NetBSD only. 33 # 34 # * `locks`: number of file locks. Linux only. 35 # 36 # * `msgqueue`: size of message queues, in bytes. Linux only. 37 # 38 # * `nice`: ceiling of 20 - nice value. Linux only. 39 # 40 # * `rtprio`: real time priority. Linux only. 41 # 42 # * `rttime`: real-time CPU time, in seconds. Linux only. 43 # 44 # * `sigpending`: number of signals queued. Linux only. 45 # 46 # For the exact semantics of each resource, see the man page of `getrlimit`: 47 # [Linux](https://man7.org/linux/man-pages/man2/setrlimit.2.html), 48 # [macOS](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getrlimit.2.html), 49 # [FreeBSD](https://www.freebsd.org/cgi/man.cgi?query=getrlimit), 50 # [NetBSD](https://man.netbsd.org/getrlimit.2), 51 # [OpenBSD](https://man.openbsd.org/getrlimit.2). A key `foo` in the Elvish API 52 # corresponds to `RLIMIT_FOO` in the C API. 53 # 54 # Examples: 55 # 56 # ```elvish-transcript 57 # ~> put $unix:rlimits 58 # ▶ [&nofile=[&cur=(num 256)] &fsize=[&] &nproc=[&max=(num 2666) &cur=(num 2666)] &memlock=[&] &cpu=[&] &core=[&cur=(num 0)] &stack=[&max=(num 67092480) &cur=(num 8372224)] &rss=[&] &data=[&]] 59 # ~> # mimic Bash's "ulimit -a" 60 # ~> keys $unix:rlimits | order | each {|key| 61 # var m = $unix:rlimits[$key] 62 # fn get {|k| if (has-key $m $k) { put $m[$k] } else { put unlimited } } 63 # printf "%-7v %-9v %-9v\n" $key (get cur) (get max) 64 # } 65 # core 0 unlimited 66 # cpu unlimited unlimited 67 # data unlimited unlimited 68 # fsize unlimited unlimited 69 # memlock unlimited unlimited 70 # nofile 256 unlimited 71 # nproc 2666 2666 72 # rss unlimited unlimited 73 # stack 8372224 67092480 74 # ~> # Decrease the soft limit on file descriptors 75 # ~> set unix:rlimits[nofile][cur] = 100 76 # ~> put $unix:rlimits[nofile] 77 # ▶ [&cur=(num 100)] 78 # ~> # Remove the soft limit on file descriptors 79 # ~> del unix:rlimits[nofile][cur] 80 # ~> put $unix:rlimits[nofile] 81 # ▶ [&] 82 # ``` 83 var rlimits