source: rtems/cpukit/posix/src/psignal.c @ e97806a

5
Last change on this file since e97806a was e97806a, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 14, 2018 at 5:20:05 PM

posix: Split posix_api_configuration_table

Use separate configuration variables to avoid false dependencies.

Update #2514.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief POSIX Signals Manager Initialization
5 *  @ingroup POSIX_SIGNALS
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <errno.h>
22#include <signal.h>
23#include <string.h>
24#include <stdlib.h>
25
26#include <rtems/score/isrlevel.h>
27#include <rtems/score/threadimpl.h>
28#include <rtems/score/threadqimpl.h>
29#include <rtems/score/watchdogimpl.h>
30#include <rtems/score/wkspace.h>
31#include <rtems/posix/threadsup.h>
32#include <rtems/posix/psignalimpl.h>
33#include <rtems/posix/pthreadimpl.h>
34#include <rtems/config.h>
35#include <rtems/seterr.h>
36#include <rtems/sysinit.h>
37
38/*
39 *  Ensure we have the same number of vectors and default vector entries
40 */
41RTEMS_STATIC_ASSERT(
42  sizeof( _POSIX_signals_Vectors ) == sizeof( _POSIX_signals_Default_vectors ),
43  posix_signals_vectors
44);
45
46/*** PROCESS WIDE STUFF ****/
47
48sigset_t  _POSIX_signals_Pending;
49
50void _POSIX_signals_Abnormal_termination_handler(
51  int signo RTEMS_UNUSED )
52{
53  exit( 1 );
54}
55
56#define SIG_ARRAY_MAX  (SIGRTMAX + 1)
57const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ] = {
58  /* NO SIGNAL 0 */  SIGACTION_IGNORE,
59  /* SIGHUP    1 */  SIGACTION_TERMINATE,
60  /* SIGINT    2 */  SIGACTION_TERMINATE,
61  /* SIGQUIT   3 */  SIGACTION_TERMINATE,
62  /* SIGILL    4 */  SIGACTION_TERMINATE,
63  /* SIGTRAP   5 */  SIGACTION_TERMINATE,
64  /* SIGIOT    6 */  SIGACTION_TERMINATE,
65  /* SIGABRT   6     SIGACTION_TERMINATE, -- alias for SIGIOT */
66  /* SIGEMT    7 */  SIGACTION_TERMINATE,
67  /* SIGFPE    8 */  SIGACTION_TERMINATE,
68  /* SIGKILL   9 */  SIGACTION_TERMINATE,
69  /* SIGBUS   10 */  SIGACTION_TERMINATE,
70  /* SIGSEGV  11 */  SIGACTION_TERMINATE,
71  /* SIGSYS   12 */  SIGACTION_TERMINATE,
72  /* SIGPIPE  13 */  SIGACTION_TERMINATE,
73  /* SIGALRM  14 */  SIGACTION_TERMINATE,
74  /* SIGTERM  15 */  SIGACTION_TERMINATE,
75  /* SIGURG   16 */  SIGACTION_TERMINATE,
76  /* SIGSTOP  17 */  SIGACTION_TERMINATE,
77  /* SIGTSTP  18 */  SIGACTION_TERMINATE,
78  /* SIGCONT  19 */  SIGACTION_TERMINATE,
79  /* SIGCHLD  20 */  SIGACTION_TERMINATE,
80  /* SIGTTIN  21 */  SIGACTION_TERMINATE,
81  /* SIGTTOU  22 */  SIGACTION_TERMINATE,
82  /* SIGIO    23 */  SIGACTION_TERMINATE,
83  /* SIGWINCH 24 */  SIGACTION_TERMINATE,
84  /* SIGUSR1  25 */  SIGACTION_TERMINATE,
85  /* SIGUSR2  26 */  SIGACTION_TERMINATE,
86  /* SIGRT    27 */  SIGACTION_TERMINATE,
87  /* SIGRT    28 */  SIGACTION_TERMINATE,
88  /* SIGRT    29 */  SIGACTION_TERMINATE,
89  /* SIGRT    30 */  SIGACTION_TERMINATE,
90  /* SIGRTMAX 31 */  SIGACTION_TERMINATE
91};
92
93struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ];
94
95Thread_queue_Control _POSIX_signals_Wait_queue =
96  THREAD_QUEUE_INITIALIZER( "POSIX Signals" );
97
98Chain_Control _POSIX_signals_Inactive_siginfo;
99Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
100
101static void _POSIX_signals_Manager_Initialization(void)
102{
103  uint32_t   signo;
104  uint32_t   maximum_queued_signals;
105
106  maximum_queued_signals = _Configuration_POSIX_Maximum_queued_signals;
107
108  memcpy(
109    _POSIX_signals_Vectors,
110    _POSIX_signals_Default_vectors,
111    sizeof( _POSIX_signals_Vectors )
112  );
113
114  /*
115   *  Initialize the set of pending signals for the entire process
116   */
117  sigemptyset( &_POSIX_signals_Pending );
118
119  /* XXX status codes */
120
121  /*
122   *  Allocate the siginfo pools.
123   */
124  for ( signo=1 ; signo<= SIGRTMAX ; signo++ )
125    _Chain_Initialize_empty( &_POSIX_signals_Siginfo[ signo ] );
126
127  if ( maximum_queued_signals ) {
128    _Chain_Initialize(
129      &_POSIX_signals_Inactive_siginfo,
130      _Workspace_Allocate_or_fatal_error(
131        maximum_queued_signals * sizeof( POSIX_signals_Siginfo_node )
132      ),
133      maximum_queued_signals,
134      sizeof( POSIX_signals_Siginfo_node )
135    );
136  } else {
137    _Chain_Initialize_empty( &_POSIX_signals_Inactive_siginfo );
138  }
139}
140
141RTEMS_SYSINIT_ITEM(
142  _POSIX_signals_Manager_Initialization,
143  RTEMS_SYSINIT_POSIX_SIGNALS,
144  RTEMS_SYSINIT_ORDER_MIDDLE
145);
Note: See TracBrowser for help on using the repository browser.