M
Mark Brackett
I'm a newbie to C programming...so go easy. 
I'm forking child processes, and registering a signal handler with the following:
signal(SIGTERM, DieServer);
signal(SIGINT, DieServer);
DieServer is the following:
volatile sig_atomic_t dying_in_progress = 0;
void DieServer(int sig){
int result;
char dummy[0];
if(dying_in_progress) raise(sig);
dying_in_progress = 1;
// Now do the clean up actions:
if(debug==1) printf("SERVER PARENT->Received SIGEVENT %d.\n",sig);
wait();
close(client_sockfd);
read(server_sockfd,dummy,0);
result = close(server_sockfd);
if(result==-1){
if(debug==1) printf("SERVER PARENT->Could not close socket\n");
perror("WARNING");
}
signal(sig, SIG_DFL);
raise(sig);
}
The wait() causes a core dump if there's no children. How do I fix this?
I'm forking child processes, and registering a signal handler with the following:
signal(SIGTERM, DieServer);
signal(SIGINT, DieServer);
DieServer is the following:
volatile sig_atomic_t dying_in_progress = 0;
void DieServer(int sig){
int result;
char dummy[0];
if(dying_in_progress) raise(sig);
dying_in_progress = 1;
// Now do the clean up actions:
if(debug==1) printf("SERVER PARENT->Received SIGEVENT %d.\n",sig);
wait();
close(client_sockfd);
read(server_sockfd,dummy,0);
result = close(server_sockfd);
if(result==-1){
if(debug==1) printf("SERVER PARENT->Could not close socket\n");
perror("WARNING");
}
signal(sig, SIG_DFL);
raise(sig);
}
The wait() causes a core dump if there's no children. How do I fix this?