mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-24 06:35:36 +08:00
posix: Protect access to _POSIX_signals_Vectors
Assume the sigaction() is called only from thread context. Protect against concurrent sigaction() invocations by different threads.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user