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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [sigaction.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: sigaction.c,v 1.2 2001-09-27 11:59:17 chris Exp $
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/posix/seterr.h>
22
#include <rtems/score/isr.h>
23
 
24
/*
25
 * PARAMETERS_PASSING_S is defined in ptimer.c
26
 */
27
 
28
extern void PARAMETERS_PASSING_S (int num_signal, const struct sigaction inf);
29
 
30
int 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
 

powered by: WebSVN 2.1.0

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