From 24ce2da758627620754d854b81f80f67ae328f51 Mon Sep 17 00:00:00 2001 From: turret Date: Mon, 18 Dec 2023 15:49:45 -0600 Subject: subsys: use rlimits to determine stack size --- init/init.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'init/init.c') diff --git a/init/init.c b/init/init.c index 59908d1..29c2128 100644 --- a/init/init.c +++ b/init/init.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -10,6 +11,7 @@ extern int subsystem_handle_term(int pid); int mainpid = 0; +long stack_size = 8192 * 512; char *token; /* For some reason, I get SIGSEGV'd when running because a random-ass @@ -61,6 +63,14 @@ int main(void) /* set mainpid for the subsystem service so it is fully accessible during l1 */ mainpid = getpid(); + /* set stack_size for subsystem service */ + struct rlimit *stack_rlimit = malloc(sizeof(struct rlimit)); + getrlimit(RLIMIT_STACK, stack_rlimit); + if(stack_rlimit->rlim_cur != RLIM_INFINITY) { + stack_size = stack_rlimit->rlim_cur; + } + free(stack_rlimit); + /* fetch token */ char *token_base = getenv("TOKEN"); if(!token_base) -- cgit v1.2.3