source: rtems/cpukit/posix/src/sigaction.c @ aee3d68

4.104.114.84.95
Last change on this file since aee3d68 was aee3d68, checked in by Joel Sherrill <joel.sherrill@…>, on 02/10/99 at 17:03:46

POSIX timer support modifications.

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