Rlimit_stack


 
Thread Tools Search this Thread
Operating Systems Linux Rlimit_stack
# 1  
Old 08-14-2007
Rlimit_stack

Hi,

when i tried ulimit -a in my system i got

"stack size (kbytes, -s) 10240"

Am trying to reduce the stack size using setrlimit command using the following program... but am not getting the result...
Can anybody help me in this...?


Code:
#include <sys/resource.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main (int argc, char *argv[])
{
  struct rlimit limit;

  /* Set the file size resource limit. */
  limit.rlim_cur = 65535;
/*  limit.rlim_max = 65535;*/
  if (setrlimit(RLIMIT_STACK, &limit) != 0) {
    printf("setrlimit() failed with errno=%d\n", errno);
    exit(1);
  }

  /* Get the file size resource limit. */
  if (getrlimit(RLIMIT_STACK, &limit) != 0) {
    printf("getrlimit() failed with errno=%d\n", errno);
    exit(1);
  }

  printf("The soft limit is %llu\n", limit.rlim_cur);
  printf("The hard limit is %llu\n", limit.rlim_max);
  exit(0);
}

THanks

Last edited by Neo; 08-14-2007 at 08:03 AM.. Reason: fixed code tags
# 2  
Old 08-14-2007
Quote:
Originally Posted by rvan
Am trying to reduce the stack size using setrlimit command using the following program...
The question "Why?" springs to mind.
# 3  
Old 08-14-2007
Quote:
Originally Posted by porter
The question "Why?" springs to mind.

in case of multi-processes, am scared that the processess may occupy more stack/data space which may result in memory crunch..
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Programming

RLIMIT_STACK signal's

I'am expecting a signal, but no signal is received when the stack-size reaches 10 bytes. Here in this code i'am setting rlim_cur=10bytes. To be more precise, when it reaches 10 bytes the process must receive a SIGSEGV signal? But i find no signal being received. Am i missing something in this... (0 Replies)
Discussion started by: prajwalps97
0 Replies
Login or Register to Ask a Question