5
Last change
on this file since 77fbbd6 was
c499856,
checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47
|
Change all references of rtems.com to rtems.org.
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief POSIX Function Installs signal Handler |
---|
5 | * @ingroup POSIXAPI |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * signal(2) - Install signal handler |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1989-1999. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #if HAVE_CONFIG_H |
---|
20 | #include "config.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #include <signal.h> |
---|
24 | #include <errno.h> |
---|
25 | |
---|
26 | #ifndef HAVE_SIGHANDLER_T |
---|
27 | typedef void (*sighandler_t)(int); |
---|
28 | #endif |
---|
29 | |
---|
30 | sighandler_t signal( |
---|
31 | int signum, |
---|
32 | sighandler_t handler |
---|
33 | ) |
---|
34 | { |
---|
35 | struct sigaction s; |
---|
36 | struct sigaction old; |
---|
37 | |
---|
38 | s.sa_handler = handler ; |
---|
39 | sigemptyset(&s.sa_mask); |
---|
40 | |
---|
41 | /* |
---|
42 | * Depending on which system we want to behave like, one of |
---|
43 | * the following versions should be chosen. |
---|
44 | */ |
---|
45 | |
---|
46 | /* #define signal_like_linux */ |
---|
47 | |
---|
48 | #if defined(signal_like_linux) |
---|
49 | s.sa_flags = SA_RESTART | SA_INTERRUPT | SA_NOMASK; |
---|
50 | s.sa_restorer= NULL ; |
---|
51 | #elif defined(signal_like_SVR4) |
---|
52 | s.sa_flags = SA_RESTART; |
---|
53 | #else |
---|
54 | s.sa_flags = 0; |
---|
55 | #endif |
---|
56 | |
---|
57 | sigaction( signum, &s, &old ); |
---|
58 | return (sighandler_t) old.sa_handler; |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.