diff options
-rw-r--r-- | lib/posix/posix_linux_amd64_consts.nim | 1 | ||||
-rw-r--r-- | lib/posix/posix_other_consts.nim | 1 | ||||
-rw-r--r-- | tests/stdlib/tposix.nim | 24 | ||||
-rw-r--r-- | tools/detect/detect.nim | 1 |
4 files changed, 27 insertions, 0 deletions
diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim index f3230f71d..6ac0279fc 100644 --- a/lib/posix/posix_linux_amd64_consts.nim +++ b/lib/posix/posix_linux_amd64_consts.nim @@ -453,6 +453,7 @@ const MAP_POPULATE* = cint(32768) # <sys/resource.h> const RLIMIT_NOFILE* = cint(7) +const RLIMIT_STACK* = cint(3) # <sys/select.h> const FD_SETSIZE* = cint(1024) diff --git a/lib/posix/posix_other_consts.nim b/lib/posix/posix_other_consts.nim index 08069fe9a..f4809a9c2 100644 --- a/lib/posix/posix_other_consts.nim +++ b/lib/posix/posix_other_consts.nim @@ -467,6 +467,7 @@ var POSIX_TYPED_MEM_MAP_ALLOCATABLE* {.importc: "POSIX_TYPED_MEM_MAP_ALLOCATABLE # <sys/resource.h> var RLIMIT_NOFILE* {.importc: "RLIMIT_NOFILE", header: "<sys/resource.h>".}: cint +var RLIMIT_STACK* {.importc: "RLIMIT_STACK", header: "<sys/resource.h>".}: cint # <sys/select.h> var FD_SETSIZE* {.importc: "FD_SETSIZE", header: "<sys/select.h>".}: cint diff --git a/tests/stdlib/tposix.nim b/tests/stdlib/tposix.nim index c5e820836..060482229 100644 --- a/tests/stdlib/tposix.nim +++ b/tests/stdlib/tposix.nim @@ -62,3 +62,27 @@ when not defined(windows): ) doAssert buffer == sent doAssert bytesRead == int(MQ_MESSAGE_SIZE) + + block: + var rl: RLimit + var res = getrlimit(RLIMIT_STACK, rl) + doAssert res == 0 + + # save old value + let oldrlim = rl.rlim_cur + + # set new value + rl.rlim_cur = rl.rlim_max - 1 + res = setrlimit(RLIMIT_STACK, rl) + doAssert res == 0 + + # get new value + var rl1: RLimit + res = getrlimit(RLIMIT_STACK, rl1) + doAssert res == 0 + doAssert rl1.rlim_cur == rl.rlim_max - 1 + + # restore old value + rl.rlim_cur = oldrlim + res = setrlimit(RLIMIT_STACK, rl) + doAssert res == 0 diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim index ed1caf78c..fe233420b 100644 --- a/tools/detect/detect.nim +++ b/tools/detect/detect.nim @@ -618,6 +618,7 @@ v("MAP_POPULATE", no_other = true) header("<sys/resource.h>") v("RLIMIT_NOFILE") +v("RLIMIT_STACK") header("<sys/select.h>") v("FD_SETSIZE") |