[PATCH 01/12] posix: Use proper lock for sigaction()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 8 06:49:16 UTC 2016


Update #2555.
---
 cpukit/posix/src/sigaction.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/cpukit/posix/src/sigaction.c b/cpukit/posix/src/sigaction.c
index a2f9028..177dcd1 100644
--- a/cpukit/posix/src/sigaction.c
+++ b/cpukit/posix/src/sigaction.c
@@ -24,17 +24,8 @@
 #include <signal.h>
 #include <errno.h>
 
-#include <rtems/system.h>
-#include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/seterr.h>
-#include <rtems/score/isr.h>
-
-/*
- * PARAMETERS_PASSING_S is defined in ptimer.c
- */
-
-extern void PARAMETERS_PASSING_S (int num_signal, const struct sigaction inf);
 
 int sigaction(
   int                     sig,
@@ -42,7 +33,7 @@ int sigaction(
   struct sigaction       *__restrict oact
 )
 {
-  ISR_Level     level;
+  ISR_lock_Context lock_context;
 
   if ( !sig )
     rtems_set_errno_and_return_minus_one( EINVAL );
@@ -60,7 +51,7 @@ int sigaction(
   if ( sig == SIGKILL )
     rtems_set_errno_and_return_minus_one( EINVAL );
 
-  _Thread_Disable_dispatch();
+  _POSIX_signals_Acquire( &lock_context );
 
   if ( oact )
     *oact = _POSIX_signals_Vectors[ sig ];
@@ -77,17 +68,15 @@ int sigaction(
      *  we can just copy the provided sigaction structure into the vectors.
      */
 
-    _ISR_Disable( level );
-      if ( act->sa_handler == SIG_DFL ) {
-        _POSIX_signals_Vectors[ sig ] = _POSIX_signals_Default_vectors[ sig ];
-      } else {
-         _POSIX_signals_Clear_process_signals( sig );
-         _POSIX_signals_Vectors[ sig ] = *act;
-      }
-    _ISR_Enable( level );
+    if ( act->sa_handler == SIG_DFL ) {
+      _POSIX_signals_Vectors[ sig ] = _POSIX_signals_Default_vectors[ sig ];
+    } else {
+       _POSIX_signals_Clear_process_signals( sig );
+       _POSIX_signals_Vectors[ sig ] = *act;
+    }
   }
 
-  _Thread_Enable_dispatch();
+  _POSIX_signals_Release( &lock_context );
 
   return 0;
 }
-- 
1.8.4.5



More information about the devel mailing list