[rtems commit] posix: Protect access to _POSIX_signals_Vectors

Sebastian Huber sebh at rtems.org
Tue Aug 27 08:44:49 UTC 2013


Module:    rtems
Branch:    master
Commit:    58a58896107d0493da0cc83a6b6b8089687eb2b4
Changeset: http://git.rtems.org/rtems/commit/?id=58a58896107d0493da0cc83a6b6b8089687eb2b4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Aug 26 14:58:07 2013 +0200

posix: Protect access to _POSIX_signals_Vectors

Assume the sigaction() is called only from thread context.  Protect
against concurrent sigaction() invocations by different threads.

---

 cpukit/posix/src/sigaction.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/cpukit/posix/src/sigaction.c b/cpukit/posix/src/sigaction.c
index 8dacc70..d5300eb 100644
--- a/cpukit/posix/src/sigaction.c
+++ b/cpukit/posix/src/sigaction.c
@@ -44,9 +44,6 @@ int sigaction(
 {
   ISR_Level     level;
 
-  if ( oact )
-    *oact = _POSIX_signals_Vectors[ sig ];
-
   if ( !sig )
     rtems_set_errno_and_return_minus_one( EINVAL );
 
@@ -63,6 +60,11 @@ int sigaction(
   if ( sig == SIGKILL )
     rtems_set_errno_and_return_minus_one( EINVAL );
 
+  _Thread_Disable_dispatch();
+
+  if ( oact )
+    *oact = _POSIX_signals_Vectors[ sig ];
+
   /*
    *  Evaluate the new action structure and set the global signal vector
    *  appropriately.
@@ -85,14 +87,7 @@ int sigaction(
     _ISR_Enable( level );
   }
 
-  /*
-   *  No need to evaluate or dispatch because:
-   *
-   *    + If we were ignoring the signal before, none could be pending
-   *      now (signals not posted when SIG_IGN).
-   *    + If we are now ignoring a signal that was previously pending,
-   *      we clear the pending signal indicator.
-   */
+  _Thread_Enable_dispatch();
 
   return 0;
 }




More information about the vc mailing list