i would like to know how i can use some the environmental variable inside a c program .
iam working in linux platform .
If u can give me an idea it would be great
i have given the code here .
somewhere there is a segmentation fault .
iam unable to find out .could u help me .
the main aim of the code is to run a particular process
"get" at an interval as specified in the ENv variable "TIME" .
The process is getting executed once but the second time iam getting a segmentation fault error .
iam not able to pass through it .
if can put ur idea it would be useful.
ramki
THE CODE :
-----------
#include<stdio.h>
#include<signal.h>
#include<time.h>
#include<unistd.h>
#include<errno.h>
#include<stdlib.h>
#include "/home/ipcpe/process/lib/ERR_logerror.c"
#define CONFIG "/home/ipcpe/process/config.ini"
#define YES 1
#define NO 0
#define TRUE 1
#define FALSE 0
/*********Global Variables ***********/
int CDRcoll_pid = -1; /* pid of the get process */
int CDRdaemon_pid; /* pid of this daemon */
FILE *fp1;
/******************Function Declaration *******************/
int collt();
void sigtrap();
void sigcld();
void sigalrm();
main()
{
char *ptr,*getenv();
char c;
int sig,i;
/********** Change to the root ************/
chdir("/"
/************ Mask the file permissions*******/
umask(0);
/**************** set the effective gid and pid ************/
setpgrp();
/**********The Following Signals are ignored *********/
signal(SIGHUP,SIG_IGN);
signal(SIGINT,SIG_IGN);
signal(SIGQUIT,SIG_IGN);
/***********For the following Signals execute sigtrap ************/
I tried to compile your program on a Sun Sparc but
i got the following unresolveds.
sigtrap
sigcld
sigalrm.
You are including a file which is not included in your
program. If I remove references to the above symbols I dont
get a segmentation fault when I run a 2nd time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.