/* signals.c

   Shane Eisenman - 11/2002

   This file contains the signal handler
   used by the chat application in chat.c
*/

/*--------------------------------------*/
#include "signals.h"
#include "common.h"
/*--------------------------------------*/
void SIGALRM_Handler(int s) {

  printf("no response from Admin...giving up\n");
  exit(1);
}
/*--------------------------------------*/
void Set_Alarm_Action() {

  struct sigaction sa;

  sa.sa_handler = SIGALRM_Handler;
  sigemptyset(&sa.sa_mask);
  //sa.sa_flags = SA_RESTART;

  if (sigaction(SIGALRM, &sa, NULL) == -1)
    Err_Exit("sigaction");

}
/*--------------------------------------*/

void Reaper() {

  struct sigaction sa;

  // reap all dead processes
  sa.sa_handler = SIGCHLD_Handler; 
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = SA_RESTART;

  if (sigaction(SIGCHLD, &sa, NULL) == -1)
    Err_Exit("sigaction");

}
/*--------------------------------------*/
void SIGCHLD_Handler(int s) {

  //while(wait(NULL) > 0);
  exit(0);

}
/*--------------------------------------*/
