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
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)