I'm a newbie to C programming...s o 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_progre ss = 0;
void DieServer(int sig){
int result;
char dummy[0];
if(dying_in_pro gress) raise(sig);
dying_in_progre ss = 1;
// Now do the clean up actions:
if(debug==1) printf("SERVER PARENT->Received SIGEVENT %d.\n",sig);
wait();
close(client_so ckfd);
read(server_soc kfd,dummy,0);
result = close(server_so ckfd);
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_progre ss = 0;
void DieServer(int sig){
int result;
char dummy[0];
if(dying_in_pro gress) raise(sig);
dying_in_progre ss = 1;
// Now do the clean up actions:
if(debug==1) printf("SERVER PARENT->Received SIGEVENT %d.\n",sig);
wait();
close(client_so ckfd);
read(server_soc kfd,dummy,0);
result = close(server_so ckfd);
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?
Comment