Changeset 3c20d28 in rtems


Ignore:
Timestamp:
May 17, 2016, 11:39:15 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ae0f048
Parents:
9d8ee11
git-author:
Sebastian Huber <sebastian.huber@…> (05/17/16 11:39:15)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/17/16 11:41:56)
Message:

posix: Fix return states of pthread_kill()

POSIX mandates that an error code is returned and not -1 plus errno.

Close #2715.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/pthreadkill.c

    r9d8ee11 r3c20d28  
    2929#include <rtems/score/isr.h>
    3030#include <rtems/score/threadimpl.h>
    31 #include <rtems/seterr.h>
    3231
    3332int pthread_kill(
     
    4039  Objects_Locations  location;
    4140
    42   if ( !sig )
    43     rtems_set_errno_and_return_minus_one( EINVAL );
    44 
    45   if ( !is_valid_signo(sig) )
    46     rtems_set_errno_and_return_minus_one( EINVAL );
     41  if ( !is_valid_signo( sig ) ) {
     42    return EINVAL;
     43  }
    4744
    4845  the_thread = _Thread_Get( thread, &location );
     
    5653      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
    5754
    58       if ( sig ) {
     55      if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
     56        _Objects_Put( &the_thread->Object );
     57        return 0;
     58      }
    5959
    60         if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
    61           _Objects_Put( &the_thread->Object );
    62           return 0;
    63         }
     60      /* XXX critical section */
    6461
    65         /* XXX critical section */
     62      api->signals_pending |= signo_to_mask( sig );
    6663
    67         api->signals_pending |= signo_to_mask( sig );
    68 
    69         (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
    70       }
     64      (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
    7165      _Objects_Put( &the_thread->Object );
    7266      return 0;
     
    7973  }
    8074
    81   rtems_set_errno_and_return_minus_one( ESRCH );
     75  return ESRCH;
    8276}
  • testsuites/psxtests/psx04/init.c

    r9d8ee11 r3c20d28  
    549549
    550550  status = pthread_kill( Init_id, 999 );
    551   if ( status != -1 )
    552     printf( "status = %d\n", status );
    553   rtems_test_assert( errno == EINVAL );
     551  rtems_test_assert( status == EINVAL );
    554552  puts( "Init: pthread_kill - EINVAL (sig invalid)" );
    555553
    556554  status = pthread_kill( Init_id, 0 );
    557   if ( status != -1 )
    558     printf( "status = %d\n", status );
    559   rtems_test_assert( errno == EINVAL );
     555  rtems_test_assert( status == EINVAL );
    560556  puts( "Init: pthread_kill - EINVAL (signal = 0)" );
    561557
Note: See TracChangeset for help on using the changeset viewer.