File: signals.c

package info (click to toggle)
netstd 3.07-2hamm.5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 6,384 kB
  • ctags: 9,087
  • sloc: ansic: 72,547; cpp: 6,141; makefile: 1,681; yacc: 1,615; sh: 1,220; perl: 303; awk: 46
file content (43 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (7)
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
34
35
36
37
38
39
40
41
42
43
/*
 * Signal handling
 *
 * Copyright (C) 1998, Olaf Kirch <okir@monad.swb.de>
 */

#include "system.h"
#include "signals.h"

#ifdef HAVE_BSD_SIGNALS
/*
 * BSD signal semantics, i.e. no need to reinstall signal handler
 */
void
install_signal_handler(int signo, RETSIGTYPE (*handler)(int))
{
	(void) signal(signo, handler);
}
#else
/*
 * Hopefully we have POSIX signals...
 */
void
install_signal_handler(int signo, RETSIGTYPE (*handler)(int))
{
	struct sigaction	act;

	memset(&act, 0, sizeof(act));
	sigemptyset(&act.sa_mask);
	act.sa_handler = handler;

	sigaction(signo, &act, NULL);
}
#endif

/*
 * Currently, common for both flavors
 */
void
ignore_signal(int signo)
{
	(void) signal(signo, SIG_IGN);
}