source: rtems/cpukit/posix/src/sigaction.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was 14d9ae4, checked in by Joel Sherrill <joel.sherrill@…>, on 08/05/09 at 21:39:49

2009-08-05 Joel Sherrill <joel.sherrill@…>

  • posix/src/sigaction.c: _POSIX_signals_Clear_process_signals now takes signal number not mask.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  3.3.4 Examine and Change Signal Action, P1003.1b-1993, p. 70
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <pthread.h>
19#include <signal.h>
20#include <errno.h>
21
22#include <rtems/system.h>
23#include <rtems/posix/pthread.h>
24#include <rtems/posix/psignal.h>
25#include <rtems/seterr.h>
26#include <rtems/score/isr.h>
27
28/*
29 * PARAMETERS_PASSING_S is defined in ptimer.c
30 */
31
32extern void PARAMETERS_PASSING_S (int num_signal, const struct sigaction inf);
33
34int sigaction(
35  int                     sig,
36  const struct sigaction *act,
37  struct sigaction       *oact
38)
39{
40  ISR_Level     level;
41
42  if ( oact )
43    *oact = _POSIX_signals_Vectors[ sig ];
44
45  if ( !sig )
46    rtems_set_errno_and_return_minus_one( EINVAL );
47
48  if ( !is_valid_signo(sig) )
49    rtems_set_errno_and_return_minus_one( EINVAL );
50
51  /*
52   *  Some signals cannot be ignored (P1003.1b-1993, pp. 70-72 and references.
53   *
54   *  NOTE: Solaris documentation claims to "silently enforce" this which
55   *        contradicts the POSIX specification.
56   */
57
58  if ( sig == SIGKILL )
59    rtems_set_errno_and_return_minus_one( EINVAL );
60
61  /*
62   *  Evaluate the new action structure and set the global signal vector
63   *  appropriately.
64   */
65
66  if ( act ) {
67
68    /*
69     *  Unless the user is installing the default signal actions, then
70     *  we can just copy the provided sigaction structure into the vectors.
71     */
72
73    _ISR_Disable( level );
74      if ( act->sa_handler == SIG_DFL ) {
75        _POSIX_signals_Vectors[ sig ] = _POSIX_signals_Default_vectors[ sig ];
76      } else {
77         _POSIX_signals_Clear_process_signals( sig );
78         _POSIX_signals_Vectors[ sig ] = *act;
79      }
80    _ISR_Enable( level );
81  }
82
83  /*
84   *  No need to evaluate or dispatch because:
85   *
86   *    + If we were ignoring the signal before, none could be pending
87   *      now (signals not posted when SIG_IGN).
88   *    + If we are now ignoring a signal that was previously pending,
89   *      we clear the pending signal indicator.
90   */
91
92  return 0;
93}
Note: See TracBrowser for help on using the repository browser.