source: rtems/cpukit/posix/src/sigaction.c @ 0c5317d

4.115
Last change on this file since 0c5317d was 0c5317d, checked in by Sebastian Huber <sebastian.huber@…>, on 07/19/13 at 12:33:56

posix: Create pthread implementation header

Move implementation specific parts of pthread.h and pthread.inl into new
header file pthreadimpl.h. The pthread.h contains now only the
application visible API.

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