source: rtems/cpukit/posix/src/sigaction.c @ 188c82b

4.104.114.84.95
Last change on this file since 188c82b was 188c82b, checked in by Joel Sherrill <joel.sherrill@…>, on 08/30/00 at 17:12:55

2000-08-30 Joel Sherrill <joel@…>

  • Many files: Moved posix/include/rtems/posix/seterr.h to score/include/rtems/seterr.h so it would be available within all APIs.
  • Property mode set to 100644
File size: 2.1 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.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14
15#include <pthread.h>
16#include <errno.h>
17
18#include <rtems/system.h>
19#include <rtems/posix/pthread.h>
20#include <rtems/posix/psignal.h>
21#include <rtems/seterr.h>
22#include <rtems/score/isr.h>
23
24/*
25 * PARAMETERS_PASSING_S is defined in ptimer.c
26 */
27
28extern void PARAMETERS_PASSING_S (int num_signal, const struct sigaction inf);
29
30int sigaction(
31  int                     sig,
32  const struct sigaction *act,
33  struct sigaction       *oact
34)
35{
36  ISR_Level     level;
37
38  if ( oact )
39    *oact = _POSIX_signals_Vectors[ sig ];
40
41  if ( !sig )
42    return 0;
43
44  if ( !is_valid_signo(sig) )
45    set_errno_and_return_minus_one( EINVAL );
46 
47  /*
48   *  Some signals cannot be ignored (P1003.1b-1993, pp. 70-72 and references.
49   *
50   *  NOTE: Solaris documentation claims to "silently enforce" this which
51   *        contradicts the POSIX specification.
52   */
53
54  if ( sig == SIGKILL )
55    set_errno_and_return_minus_one( EINVAL );
56 
57  /*
58   *  Evaluate the new action structure and set the global signal vector
59   *  appropriately.
60   */
61
62  if ( act ) {
63
64    /*
65     *  Unless the user is installing the default signal actions, then
66     *  we can just copy the provided sigaction structure into the vectors.
67     */
68
69    _ISR_Disable( level );
70      if ( act->sa_handler == SIG_DFL ) {
71        _POSIX_signals_Vectors[ sig ] = _POSIX_signals_Default_vectors[ sig ];
72      } else {
73         _POSIX_signals_Clear_process_signals( signo_to_mask(sig) );
74         _POSIX_signals_Vectors[ sig ] = *act;
75      }
76    _ISR_Enable( level );
77  }
78
79  /*
80   *  No need to evaluate or dispatch because:
81   *
82   *    + If we were ignoring the signal before, none could be pending
83   *      now (signals not posted when SIG_IGN).
84   *    + If we are now ignoring a signal that was previously pending,
85   *      we clear the pending signal indicator.
86   */
87
88  return 0;
89}
90
Note: See TracBrowser for help on using the repository browser.