summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/sigsuspend.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-27 16:38:15 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-27 16:38:15 +0000
commitc9bc2cf62f6d24f609e6e9b426b86b80c342ba88 (patch)
tree4618cbad89ffca0c410b2c285b8896a9c10660ef /cpukit/posix/src/sigsuspend.c
parent2010-07-27 Vinu Rajashekhar <vinutheraj@gmail.com> (diff)
downloadrtems-c9bc2cf62f6d24f609e6e9b426b86b80c342ba88.tar.bz2
2010-07-27 Vinu Rajashekhar <vinutheraj@gmail.com>
PR 1629/cpukit * posix/src/sigsuspend.c: sigsuspend() was not completely following the POSIX specification.
Diffstat (limited to 'cpukit/posix/src/sigsuspend.c')
-rw-r--r--cpukit/posix/src/sigsuspend.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/cpukit/posix/src/sigsuspend.c b/cpukit/posix/src/sigsuspend.c
index aa330bc71c..606e8556f5 100644
--- a/cpukit/posix/src/sigsuspend.c
+++ b/cpukit/posix/src/sigsuspend.c
@@ -15,6 +15,7 @@
#include "config.h"
#endif
+#include <assert.h>
#include <signal.h>
#include <errno.h>
@@ -28,17 +29,21 @@ int sigsuspend(
)
{
sigset_t saved_signals_blocked;
- sigset_t all_signals;
+ sigset_t current_unblocked_signals;
int status;
POSIX_API_Control *api;
api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
+ /*
+ * We use SIG_BLOCK and not SIG_SETMASK because there may be
+ * signals which might be pending, which might get caught here.
+ * We want the signals to be caught inside sigtimedwait.
+ */
status = sigprocmask( SIG_BLOCK, sigmask, &saved_signals_blocked );
- (void) sigfillset( &all_signals );
-
- status = sigtimedwait( &all_signals, NULL, NULL );
+ current_unblocked_signals = ~(*sigmask);
+ status = sigtimedwait( &current_unblocked_signals, NULL, NULL );
(void) sigprocmask( SIG_SETMASK, &saved_signals_blocked, NULL );
@@ -46,8 +51,7 @@ int sigsuspend(
* sigtimedwait() returns the signal number while sigsuspend()
* is supposed to return -1 and EINTR when a signal is caught.
*/
- if ( status != -1 )
- rtems_set_errno_and_return_minus_one( EINTR );
+ assert ( status != -1 );
- return status;
+ rtems_set_errno_and_return_minus_one( EINTR );
}