diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2025-08-02 15:22:23 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2025-08-02 15:22:23 +0200 |
| commit | 25389ed086d8c12adf3fff9b5db952749c74a981 (patch) | |
| tree | 6de9cbe9b800133d81174d3eb6fc8724f0e22c2f | |
| parent | 710203eadb605b41e652084297cde54754008b87 (diff) | |
thread: set stack size to rlimit
| -rw-r--r-- | core/thread/thread_unix.odin | 7 |
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 { |