source: rtems/c/src/exec/posix/src/sigaction.c @ 781262bb

4.104.114.84.95
Last change on this file since 781262bb was 781262bb, checked in by Joel Sherrill <joel.sherrill@…>, on 10/31/00 at 16:33:48

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

  • include/Makefile.am: Updated to reflect files merged into newlib. This resulted in some definitions moving to other files and thus some secondary effects in RTEMS source code.
  • include/unistd.h: Removed. Now use newlib's.
  • include/rtems/posix/mqueue.h: Add include of <signal.h>.
  • include/rtems/posix/threadsup.h: Add include of <sys/signal.h>
  • src/execv.c: Corrected prototype to agree with newlib.
  • src/execve.c: Corrected prototype to agree with newlib.
  • src/execvp.c: Corrected prototype to agree with newlib.
  • src/psignal.c: Rewrote reference to <siginfo.h> in comment since that file no longer exists.
  • src/pthreadkill.c: Added include of <signal.h>.
  • src/sigaction.c: Added include of <signal.h>.
  • src/sigtimedwait.c: Rewrote reference to <siginfo.h> in comment since that file no longer exists. *
  • 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 <signal.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/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.