From 138aa38dead219cc0687187780040a9a20ba3dec Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 21 May 2004 20:19:33 +0000 Subject: 2004-05-21 Joel Sherrill PR 628/rtems * posix/src/killinfo.c, posix/src/pthreadkill.c, posix/src/ptimer1.c, posix/src/sigaction.c, posix/src/sigaddset.c, posix/src/sigsuspend.c: Signal set of 0 is supposed to return EINVAL. In addition timer_create needed to return an error if the clock was not CLOCK_REALTIME. --- cpukit/posix/src/killinfo.c | 10 ++++++---- cpukit/posix/src/pthreadkill.c | 5 ++++- cpukit/posix/src/ptimer1.c | 9 +++++++++ cpukit/posix/src/sigaction.c | 2 +- cpukit/posix/src/sigaddset.c | 2 +- cpukit/posix/src/sigsuspend.c | 10 +++++++++- 6 files changed, 30 insertions(+), 8 deletions(-) (limited to 'cpukit/posix') diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c index 945306e697..b275a0b764 100644 --- a/cpukit/posix/src/killinfo.c +++ b/cpukit/posix/src/killinfo.c @@ -66,18 +66,20 @@ int killinfo( rtems_set_errno_and_return_minus_one( ESRCH ); /* - * Validate the signal passed if not 0. + * Validate the signal passed. */ - if ( sig && !is_valid_signo(sig) ) { + if ( !sig ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + if ( !is_valid_signo(sig) ) rtems_set_errno_and_return_minus_one( EINVAL ); - } /* * If the signal is being ignored, then we are out of here. */ - if ( !sig || _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) { + if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) { return 0; } diff --git a/cpukit/posix/src/pthreadkill.c b/cpukit/posix/src/pthreadkill.c index 6a1a7b4c86..c6624eb8be 100644 --- a/cpukit/posix/src/pthreadkill.c +++ b/cpukit/posix/src/pthreadkill.c @@ -34,7 +34,10 @@ int pthread_kill( Thread_Control *the_thread; Objects_Locations location; - if ( sig && !is_valid_signo(sig) ) + if ( !sig ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + if ( !is_valid_signo(sig) ) rtems_set_errno_and_return_minus_one( EINVAL ); /* commented out when posix timers added diff --git a/cpukit/posix/src/ptimer1.c b/cpukit/posix/src/ptimer1.c index 6f7ec2466f..368dff43ff 100644 --- a/cpukit/posix/src/ptimer1.c +++ b/cpukit/posix/src/ptimer1.c @@ -271,6 +271,9 @@ int timer_create( rtems_id timer_id; /* created timer identifier */ int timer_pos; /* Position in the table of timers */ + if ( clock_id != CLOCK_REALTIME ) + rtems_set_errno_and_return_minus_one( EINVAL ); + /* * The data of the structure evp are checked in order to verify if they * are coherent. @@ -283,6 +286,12 @@ int timer_create( /* The value of the field sigev_notify is not valid */ rtems_set_errno_and_return_minus_one( EINVAL ); } + + if ( !evp->sigev_signo ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + if ( !is_valid_signo(evp->sigev_signo) ) + rtems_set_errno_and_return_minus_one( EINVAL ); } /* diff --git a/cpukit/posix/src/sigaction.c b/cpukit/posix/src/sigaction.c index b986d97ba1..a8d48f9f3b 100644 --- a/cpukit/posix/src/sigaction.c +++ b/cpukit/posix/src/sigaction.c @@ -43,7 +43,7 @@ int sigaction( *oact = _POSIX_signals_Vectors[ sig ]; if ( !sig ) - return 0; + rtems_set_errno_and_return_minus_one( EINVAL ); if ( !is_valid_signo(sig) ) rtems_set_errno_and_return_minus_one( EINVAL ); diff --git a/cpukit/posix/src/sigaddset.c b/cpukit/posix/src/sigaddset.c index 7f738771b0..5ac0fe0f17 100644 --- a/cpukit/posix/src/sigaddset.c +++ b/cpukit/posix/src/sigaddset.c @@ -32,7 +32,7 @@ int sigaddset( rtems_set_errno_and_return_minus_one( EINVAL ); if ( !signo ) - return 0; + rtems_set_errno_and_return_minus_one( EINVAL ); if ( !is_valid_signo(signo) ) rtems_set_errno_and_return_minus_one( EINVAL ); diff --git a/cpukit/posix/src/sigsuspend.c b/cpukit/posix/src/sigsuspend.c index aca97a868d..aa330bc71c 100644 --- a/cpukit/posix/src/sigsuspend.c +++ b/cpukit/posix/src/sigsuspend.c @@ -1,7 +1,7 @@ /* * 3.3.7 Wait for a Signal, P1003.1b-1993, p. 75 * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2004. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -21,6 +21,7 @@ #include #include #include +#include int sigsuspend( const sigset_t *sigmask @@ -41,5 +42,12 @@ int sigsuspend( (void) sigprocmask( SIG_SETMASK, &saved_signals_blocked, NULL ); + /* + * 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 ); + return status; } -- cgit v1.2.3