File: sig.c

package info (click to toggle)
safecat 1.0-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 200 kB
  • ctags: 23
  • sloc: ansic: 213; sh: 164; makefile: 118
file content (28 lines) | stat: -rw-r--r-- 860 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "config.h"
#include <signal.h>
#include <stdio.h>

/* ****************************************************************** */
RETSIGTYPE alarm_handler(int sig) {
  fprintf(stderr, "Timer has expired.  Giving up.\n");
  exit(-1);
}
/* ****************************************************************** */


/* ****************************************************************** 
   This function was pretty much lifted from Qmail code.  Thanks to
   Professor Bernstein. 
   ****************************************************************** */
void set_handler(int sig, RETSIGTYPE (*h)()) {
#ifdef HAVE_SIGACTION
  struct sigaction sa;
  sa.sa_handler = h;
  sa.sa_flags = 0;
  sigemptyset(&sa.sa_mask);
  sigaction(sig,&sa,(struct sigaction *) 0);
#else
  signal(sig,h);
#endif
}
/* ****************************************************************** */