source: rtems/cpukit/posix/src/sigaction.c @ 77fbbd6

5
Last change on this file since 77fbbd6 was 93306058, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 12:43:19

score: _CORE_mutex_Check_dispatch_for_seize()

Move the safety check performed by
_CORE_mutex_Check_dispatch_for_seize() out of the performance critical
path and generalize it. Blocking on a thread queue with an unexpected
thread dispatch disabled level is illegal in all system states.

Add the expected thread dispatch disable level (which may be 1 or 2
depending on the operation) to Thread_queue_Context and use it in
_Thread_queue_Enqueue_critical().

  • Property mode set to 100644
File size: 1.9 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.org/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/posix/psignalimpl.h>
28#include <rtems/seterr.h>
29
30int sigaction(
31  int                     sig,
32  const struct sigaction *__restrict act,
33  struct sigaction       *__restrict oact
34)
35{
36  Thread_queue_Context queue_context;
37
38  if ( !sig )
39    rtems_set_errno_and_return_minus_one( EINVAL );
40
41  if ( !is_valid_signo(sig) )
42    rtems_set_errno_and_return_minus_one( EINVAL );
43
44  /*
45   *  Some signals cannot be ignored (P1003.1b-1993, pp. 70-72 and references.
46   *
47   *  NOTE: Solaris documentation claims to "silently enforce" this which
48   *        contradicts the POSIX specification.
49   */
50
51  if ( sig == SIGKILL )
52    rtems_set_errno_and_return_minus_one( EINVAL );
53
54  _Thread_queue_Context_initialize( &queue_context );
55  _POSIX_signals_Acquire( &queue_context );
56
57  if ( oact )
58    *oact = _POSIX_signals_Vectors[ sig ];
59
60  /*
61   *  Evaluate the new action structure and set the global signal vector
62   *  appropriately.
63   */
64
65  if ( act ) {
66
67    /*
68     *  Unless the user is installing the default signal actions, then
69     *  we can just copy the provided sigaction structure into the vectors.
70     */
71
72    if ( act->sa_handler == SIG_DFL ) {
73      _POSIX_signals_Vectors[ sig ] = _POSIX_signals_Default_vectors[ sig ];
74    } else {
75       _POSIX_signals_Clear_process_signals( sig );
76       _POSIX_signals_Vectors[ sig ] = *act;
77    }
78  }
79
80  _POSIX_signals_Release( &queue_context );
81
82  return 0;
83}
Note: See TracBrowser for help on using the repository browser.