source: rtems/cpukit/posix/src/sigaction.c @ 6a3a81c

4.104.114.84.95
Last change on this file since 6a3a81c was e180a77e, checked in by Joel Sherrill <joel.sherrill@…>, on 01/04/02 at 18:28:24

2002-01-04 Ralf Corsepius <corsepiu@…>

  • src/clockgetres.c: Apply rtems_set_errno_and_return_minus_one.
  • src/clockgettime.c: Apply rtems_set_errno_and_return_minus_one.
  • src/clocksettime.c: Apply rtems_set_errno_and_return_minus_one.
  • src/killinfo.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueueclose.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuecreatesupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuegetattr.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuenotify.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueueopen.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuerecvsupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuesendsupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueuesetattr.c: Apply rtems_set_errno_and_return_minus_one.
  • src/mqueueunlink.c: Apply rtems_set_errno_and_return_minus_one.
  • src/nanosleep.c: Apply rtems_set_errno_and_return_minus_one.
  • src/pthreadkill.c: Apply rtems_set_errno_and_return_minus_one.
  • src/pthreadsigmask.c: Apply rtems_set_errno_and_return_minus_one.
  • src/ptimer1.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sched.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semaphorecreatesupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semaphorewaitsupp.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semclose.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semdestroy.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semgetvalue.c: Apply rtems_set_errno_and_return_minus_one.
  • src/seminit.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semopen.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sempost.c: Apply rtems_set_errno_and_return_minus_one.
  • src/semunlink.c: Apply rtems_set_errno_and_return_minus_one.
  • src/setpgid.c: Apply rtems_set_errno_and_return_minus_one.
  • src/setsid.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigaction.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigaddset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigdelset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigemptyset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigfillset.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigismember.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigpending.c: Apply rtems_set_errno_and_return_minus_one.
  • src/sigtimedwait.c: Apply rtems_set_errno_and_return_minus_one.
  • src/utsname.c: Apply rtems_set_errno_and_return_minus_one.
  • 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.OARcorp.com/rtems/license.html.
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    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
Note: See TracBrowser for help on using the repository browser.