Advertisement
Gistrec

Change stack size

Sep 21st, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <sys/resource.h>
  2.  
  3. int main (int argc, char **argv) {
  4.     const rlim_t kStackSize = 16 * 1024 * 1024;   // min stack size = 16 MB
  5.     struct rlimit rl;
  6.     int result;
  7.  
  8.     result = getrlimit(RLIMIT_STACK, &rl);
  9.     if (result == 0) {
  10.         if (rl.rlim_cur < kStackSize) {
  11.             rl.rlim_cur = kStackSize;
  12.             result = setrlimit(RLIMIT_STACK, &rl);
  13.             if (result != 0) {
  14.                 fprintf(stderr, "setrlimit returned result = %d\n", result);
  15.             }
  16.         }
  17.     }
  18.  
  19.     // ...
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement