36#include <sys/resource.h>
38static void dt_set_rlimits_stack()
44 struct rlimit rlim = { 0 };
46 ret = getrlimit(RLIMIT_STACK, &rlim);
50 const int errsv = errno;
51 fprintf(stderr,
"[dt_set_rlimits_stack] error: getrlimit(RLIMIT_STACK) returned %i: %i (%s)\n", ret, errsv,
55 assert((ret == 0 && (
WANTED_STACK_SIZE <= rlim.rlim_max || RLIM_INFINITY == rlim.rlim_max)) || (ret != 0));
57 if(ret != 0 || (rlim.rlim_cur <
WANTED_STACK_SIZE && rlim.rlim_cur != RLIM_INFINITY) )
61 fprintf(stderr,
"[dt_set_rlimits_stack] info: bumping RLIMIT_STACK rlim_cur from %"PRIuMAX
" to %"PRIuMAX
"\n",
66 ret = setrlimit(RLIMIT_STACK, &rlim);
70 fprintf(stderr,
"[dt_set_rlimits_stack] error: setrlimit(RLIMIT_STACK) returned %i: %i (%s)\n", ret, errsv,
87 dt_set_rlimits_stack();
#define WANTED_STACK_SIZE
void dt_set_rlimits()
Raise the process limits Ansel needs, where the system lets a running process do it.