aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-08-02 14:58:33 +0100
committerGitHub <noreply@github.com>2025-08-02 14:58:33 +0100
commit4fac64afd48ed11f9f78fb9e85f71932adced9a4 (patch)
tree6de9cbe9b800133d81174d3eb6fc8724f0e22c2f
parent710203eadb605b41e652084297cde54754008b87 (diff)
parent25389ed086d8c12adf3fff9b5db952749c74a981 (diff)
Merge pull request #5531 from laytan/thread-stack-size-rlimit
thread: set stack size to rlimit
-rw-r--r--core/thread/thread_unix.odin7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin
index 1431442a9..1db32657e 100644
--- a/core/thread/thread_unix.odin
+++ b/core/thread/thread_unix.odin
@@ -81,8 +81,13 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
}
defer posix.pthread_attr_destroy(&attrs)
- // NOTE(tetra, 2019-11-01): These only fail if their argument is invalid.
+ stacksize: posix.rlimit
+ if res := posix.getrlimit(.STACK, &stacksize); res == .OK && stacksize.rlim_cur > 0 {
+ _ = posix.pthread_attr_setstacksize(&attrs, uint(stacksize.rlim_cur))
+ }
+
res: posix.Errno
+ // NOTE(tetra, 2019-11-01): These only fail if their argument is invalid.
res = posix.pthread_attr_setdetachstate(&attrs, .CREATE_JOINABLE)
assert(res == nil)
when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {