source: rtems/cpukit/posix/src/psignal.c @ 309e2f6

4.104.115
Last change on this file since 309e2f6 was 309e2f6, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/08 at 21:23:37

2008-12-17 Joel Sherrill <joel.sherrill@…>

  • posix/include/rtems/posix/barrier.h, posix/include/rtems/posix/cond.h, posix/include/rtems/posix/key.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/psignal.h, posix/include/rtems/posix/pthread.h, posix/include/rtems/posix/ptimer.h, posix/include/rtems/posix/rwlock.h, posix/include/rtems/posix/semaphore.h, posix/include/rtems/posix/spinlock.h, posix/include/rtems/posix/timer.h, posix/src/cond.c, posix/src/key.c, posix/src/mqueue.c, posix/src/mutex.c, posix/src/pbarrier.c, posix/src/prwlock.c, posix/src/psignal.c, posix/src/pspin.c, posix/src/pthread.c, posix/src/pthreadinitthreads.c, posix/src/ptimer.c, posix/src/semaphore.c, sapi/src/posixapi.c: Convert POSIX manager initialization routines to directly pull parameters from configuration table.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <assert.h>
17#include <errno.h>
18#include <pthread.h>
19#include <signal.h>
20#include <string.h>     /* memcpy */
21#include <stdlib.h>     /* exit */
22
23#include <rtems/system.h>
24#include <rtems/config.h>
25#include <rtems/score/isr.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/tqdata.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/seterr.h>
30#include <rtems/posix/threadsup.h>
31#include <rtems/posix/psignal.h>
32#include <rtems/posix/pthread.h>
33#include <rtems/posix/time.h>
34#include <stdio.h>
35
36/*** PROCESS WIDE STUFF ****/
37
38sigset_t  _POSIX_signals_Pending;
39
40void _POSIX_signals_Abnormal_termination_handler( int signo )
41{
42  exit( 1 );
43}
44
45#define SIG_ARRAY_MAX  (SIGRTMAX + 1)
46const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ] = {
47  /* NO SIGNAL 0 */  SIGACTION_IGNORE,
48  /* SIGHUP    1 */  SIGACTION_TERMINATE,
49  /* SIGINT    2 */  SIGACTION_TERMINATE,
50  /* SIGQUIT   3 */  SIGACTION_TERMINATE,
51  /* SIGILL    4 */  SIGACTION_TERMINATE,
52  /* SIGTRAP   5 */  SIGACTION_TERMINATE,
53  /* SIGIOT    6 */  SIGACTION_TERMINATE,
54  /* SIGABRT   6     SIGACTION_TERMINATE, -- alias for SIGIOT */
55  /* SIGEMT    7 */  SIGACTION_TERMINATE,
56  /* SIGFPE    8 */  SIGACTION_TERMINATE,
57  /* SIGKILL   9 */  SIGACTION_TERMINATE,
58  /* SIGBUS   10 */  SIGACTION_TERMINATE,
59  /* SIGSEGV  11 */  SIGACTION_TERMINATE,
60  /* SIGSYS   12 */  SIGACTION_TERMINATE,
61  /* SIGPIPE  13 */  SIGACTION_TERMINATE,
62  /* SIGALRM  14 */  SIGACTION_TERMINATE,
63  /* SIGTERM  15 */  SIGACTION_TERMINATE,
64  /* SIGURG   16 */  SIGACTION_TERMINATE,
65  /* SIGSTOP  17 */  SIGACTION_TERMINATE,
66  /* SIGTSTP  18 */  SIGACTION_TERMINATE,
67  /* SIGCONT  19 */  SIGACTION_TERMINATE,
68  /* SIGCHLD  20 */  SIGACTION_TERMINATE,
69  /* SIGTTIN  21 */  SIGACTION_TERMINATE,
70  /* SIGTTOU  22 */  SIGACTION_TERMINATE,
71  /* SIGIO    23 */  SIGACTION_TERMINATE,
72  /* SIGWINCH 24 */  SIGACTION_TERMINATE,
73  /* SIGUSR1  25 */  SIGACTION_TERMINATE,
74  /* SIGUSR2  26 */  SIGACTION_TERMINATE,
75  /* SIGRT    27 */  SIGACTION_TERMINATE,
76  /* SIGRT    28 */  SIGACTION_TERMINATE,
77  /* SIGRT    29 */  SIGACTION_TERMINATE,
78  /* SIGRT    30 */  SIGACTION_TERMINATE,
79  /* SIGRTMAX 31 */  SIGACTION_TERMINATE
80};
81
82struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ];
83
84Thread_queue_Control _POSIX_signals_Wait_queue;
85
86Chain_Control _POSIX_signals_Inactive_siginfo;
87Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
88
89/*PAGE
90 *
91 *  XXX - move these
92 */
93
94#define _States_Is_interruptible_signal( _states ) \
95  ( ((_states) & \
96    (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \
97      (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL))
98
99/*
100 *  _POSIX_signals_Post_switch_extension
101 */
102
103void _POSIX_signals_Post_switch_extension(
104  Thread_Control  *the_thread
105)
106{
107  POSIX_API_Control  *api;
108  int                 signo;
109  ISR_Level           level;
110
111  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
112  if ( !api )
113    return;
114
115  /*
116   *  If we invoke any user code, there is the possibility that
117   *  a new signal has been posted that we should process so we
118   *  restart the loop if a signal handler was invoked.
119   *
120   *  The first thing done is to check there are any signals to be
121   *  processed at all.  No point in doing this loop otherwise.
122   */
123  while (1) {
124  restart:
125    _ISR_Disable( level );
126      if ( !(~api->signals_blocked &
127            (api->signals_pending | _POSIX_signals_Pending)) ) {
128       _ISR_Enable( level );
129       break;
130     }
131    _ISR_Enable( level );
132
133    for ( signo = SIGRTMIN ; signo <= SIGRTMAX ; signo++ ) {
134
135      if ( _POSIX_signals_Check_signal( api, signo, false ) )
136        goto restart;
137
138      if ( _POSIX_signals_Check_signal( api, signo, true ) )
139        goto restart;
140
141    }
142
143    /* XXX - add __SIGFIRSTNOTRT or something like that to newlib signal .h */
144
145    for ( signo = SIGHUP ; signo <= __SIGLASTNOTRT ; signo++ ) {
146
147      if ( _POSIX_signals_Check_signal( api, signo, false ) )
148        goto restart;
149
150      if ( _POSIX_signals_Check_signal( api, signo, true ) )
151        goto restart;
152
153    }
154  }
155  return;
156}
157
158/*PAGE
159 *
160 *  _POSIX_signals_Manager_Initialization
161 */
162
163void _POSIX_signals_Manager_Initialization(void)
164{
165  uint32_t   signo;
166  uint32_t   maximum_queued_signals;
167
168  maximum_queued_signals = Configuration_POSIX_API.maximum_queued_signals;
169
170  /*
171   *  Ensure we have the same number of vectors and default vector entries
172   */
173
174  assert(
175   sizeof(_POSIX_signals_Vectors) == sizeof(_POSIX_signals_Default_vectors)
176  );
177
178  memcpy(
179    _POSIX_signals_Vectors,
180    _POSIX_signals_Default_vectors,
181    sizeof( _POSIX_signals_Vectors )
182  );
183
184  /*
185   *  Initialize the set of pending signals for the entire process
186   */
187
188  sigemptyset( &_POSIX_signals_Pending );
189
190  /*
191   *  Initialize the queue we use to block for signals
192   */
193
194  _Thread_queue_Initialize(
195    &_POSIX_signals_Wait_queue,
196    THREAD_QUEUE_DISCIPLINE_PRIORITY,
197    STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
198    EAGAIN
199  );
200
201  /* XXX status codes */
202
203  /*
204   *  Allocate the siginfo pools.
205   */
206
207  for ( signo=1 ; signo<= SIGRTMAX ; signo++ )
208    _Chain_Initialize_empty( &_POSIX_signals_Siginfo[ signo ] );
209
210  if ( maximum_queued_signals ) {
211    _Chain_Initialize(
212      &_POSIX_signals_Inactive_siginfo,
213      _Workspace_Allocate_or_fatal_error(
214        maximum_queued_signals * sizeof( POSIX_signals_Siginfo_node )
215      ),
216      maximum_queued_signals,
217      sizeof( POSIX_signals_Siginfo_node )
218    );
219  } else {
220    _Chain_Initialize_empty( &_POSIX_signals_Inactive_siginfo );
221  }
222}
Note: See TracBrowser for help on using the repository browser.