blob: 9149bf0a02069005aa3192fb5722a0707574aeb3 (
plain) (
blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/**
* @file
*
* @brief POSIX Function Installs signal Handler
* @ingroup POSIXAPI
*/
/*
* signal(2) - Install signal handler
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <signal.h>
#include <errno.h>
#ifndef HAVE_SIGHANDLER_T
typedef void (*sighandler_t)(int);
#endif
sighandler_t signal(
int signum,
sighandler_t handler
)
{
struct sigaction s;
struct sigaction old;
s.sa_handler = handler ;
sigemptyset(&s.sa_mask);
/*
* Depending on which system we want to behave like, one of
* the following versions should be chosen.
*/
/* #define signal_like_linux */
#if defined(signal_like_linux)
s.sa_flags = SA_RESTART | SA_INTERRUPT | SA_NOMASK;
s.sa_restorer= NULL ;
#elif defined(signal_like_SVR4)
s.sa_flags = SA_RESTART;
#else
s.sa_flags = 0;
#endif
sigaction( signum, &s, &old );
return (sighandler_t) old.sa_handler;
}
|