OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [src/] [sigaction.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  sigaction.c,v 1.7 2002/01/04 18:28:24 joel Exp
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
 
32
extern void PARAMETERS_PASSING_S (int num_signal, const struct sigaction inf);
33
 
34
int 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
    return 0;
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( signo_to_mask(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
}
94
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.