File: sig.c

package info (click to toggle)
safecat 1.13-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 624 kB
  • ctags: 243
  • sloc: ansic: 2,042; makefile: 334; sh: 270
file content (33 lines) | stat: -rw-r--r-- 1,005 bytes parent folder | download | duplicates (8)
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
29
30
31
32
33
/* Copyright (c) 2000, Len Budney. See COPYING for details. */

#include "hassgact.h"
#include "stralloc.h"
#include "strerr.h"
#include <signal.h>
#include <unistd.h>

/* ****************************************************************** */
extern stralloc tmppath;
void alarm_handler(int sig) {
  unlink(tmppath.s);
  strerr_die2x(111,"safecat: fatal: ","Timer has expired; giving up");
}
/* ****************************************************************** */


/* ****************************************************************** 
   This function was pretty much lifted from Qmail code.  Thanks to
   Professor Bernstein. 
   ****************************************************************** */
void set_handler(int sig, void (*h)()) {
#ifdef HASSIGACTION
  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
}
/* ****************************************************************** */