Hi,
The program design is wrong. Anyway if you the reason for your
program termination.
Normally the maximum stack size for the program is 8 MB.
You can get this by
#include<sys/resource.h>
#define MB 1024*1024
main()
{
struct rlimit rm;
getrlimit(RLIMIT_STACK,&rm);
printf("\nSTACK SIZE: MAX=%d MB CURR=%d\n",
rm.rlim_max/(MB),rm.rlim_cur/(MB));
}
If you want you program want to run some more time use setrlimit... It's
advisable that the maximum stack limit must be 16 MB less than physical
memory.
For writing daemon process make use of the library function daemon(int,int);
( #include <unistd.h>)
Hope this will help you.
Regards,
-lok.
From: Chandrashekar Babu <lug@xxxxxxxxxxxxxxxxxx>
To: Praveen <praveen@xxxxxxxxxxx>
CC: ilugc@xxxxxxxxxxxxx
Subject: Re: [Ilugc] C pgm - Recursive -segmentation fault
Date: Sun, 12 Sep 2004 00:11:57 +0530
void R()
{
static int i =0;
i++;
printf("%d\n",i);
}
int main()
{
while(1)
R();
}
This is what a daemon is.
What has daemons got to do with recursive/iterative constructs ? For all I
know, this code isn't designed to run in the background on its own, it
doesn't detached from the controlling terminal, and it also doesn't have
any form of event-loop mechanism (which I believe are minimal requirements
for calling a program a daemon).
Cheers,
Chandrashekar Babu.
_______________________________________________
To unsubscribe, email ilugc-request@xxxxxxxxxxxxx with
"unsubscribe <password> address"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc