mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 23:23:13 +00:00
posix: Fix return states of pthread_kill()
POSIX mandates that an error code is returned and not -1 plus errno. Update #2715.
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
#include <rtems/posix/pthread.h>
|
#include <rtems/posix/pthread.h>
|
||||||
#include <rtems/posix/psignal.h>
|
#include <rtems/posix/psignal.h>
|
||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
#include <rtems/seterr.h>
|
|
||||||
|
|
||||||
int pthread_kill(
|
int pthread_kill(
|
||||||
pthread_t thread,
|
pthread_t thread,
|
||||||
@@ -34,11 +33,9 @@ int pthread_kill(
|
|||||||
Thread_Control *the_thread;
|
Thread_Control *the_thread;
|
||||||
Objects_Locations location;
|
Objects_Locations location;
|
||||||
|
|
||||||
if ( !sig )
|
if ( !is_valid_signo( sig ) ) {
|
||||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
return EINVAL;
|
||||||
|
}
|
||||||
if ( !is_valid_signo(sig) )
|
|
||||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
|
||||||
|
|
||||||
the_thread = _Thread_Get( thread, &location );
|
the_thread = _Thread_Get( thread, &location );
|
||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
@@ -50,8 +47,6 @@ int pthread_kill(
|
|||||||
|
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
if ( sig ) {
|
|
||||||
|
|
||||||
if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
|
if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -67,7 +62,7 @@ int pthread_kill(
|
|||||||
|
|
||||||
if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
|
if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
|
||||||
_ISR_Signals_to_thread_executing = true;
|
_ISR_Signals_to_thread_executing = true;
|
||||||
}
|
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -78,5 +73,5 @@ int pthread_kill(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_set_errno_and_return_minus_one( ESRCH );
|
return ESRCH;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -536,9 +536,7 @@ void *POSIX_Init(
|
|||||||
puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid to large)" );
|
puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid to large)" );
|
||||||
|
|
||||||
status = pthread_kill( Init_id, 999 );
|
status = pthread_kill( Init_id, 999 );
|
||||||
if ( status != -1 )
|
rtems_test_assert( status == EINVAL );
|
||||||
printf( "status = %d\n", status );
|
|
||||||
rtems_test_assert( errno == EINVAL );
|
|
||||||
puts( "Init: pthread_kill - EINVAL (sig invalid)" );
|
puts( "Init: pthread_kill - EINVAL (sig invalid)" );
|
||||||
|
|
||||||
status = pthread_kill( 0, SIGUSR2 );
|
status = pthread_kill( 0, SIGUSR2 );
|
||||||
@@ -548,9 +546,7 @@ void *POSIX_Init(
|
|||||||
puts( "Init: pthread_kill - ESRCH (signal SA_SIGINFO)" );
|
puts( "Init: pthread_kill - ESRCH (signal SA_SIGINFO)" );
|
||||||
|
|
||||||
status = pthread_kill( Init_id, 0 );
|
status = pthread_kill( Init_id, 0 );
|
||||||
if ( status != -1 )
|
rtems_test_assert( status == EINVAL );
|
||||||
printf( "status = %d\n", status );
|
|
||||||
rtems_test_assert( errno == EINVAL );
|
|
||||||
puts( "Init: pthread_kill - EINVAL (signal = 0)" );
|
puts( "Init: pthread_kill - EINVAL (signal = 0)" );
|
||||||
|
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
|
|||||||
Reference in New Issue
Block a user