source: rtems/c/src/exec/posix/src/pthreadkill.c @ 811fae1

4.104.114.84.95
Last change on this file since 811fae1 was aee3d68, checked in by Joel Sherrill <joel.sherrill@…>, on 02/10/99 at 17:03:46

POSIX timer support modifications.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  3.3.10 Send a Signal to a Thread, P1003.1c/D10, p. 43
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15
16#include <pthread.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/posix/pthread.h>
21#include <rtems/posix/psignal.h>
22#include <rtems/score/isr.h>
23#include <rtems/posix/seterr.h>
24
25int pthread_kill(
26  pthread_t   thread,
27  int         sig
28)
29{
30  POSIX_API_Control  *api;
31  Thread_Control     *the_thread;
32  Objects_Locations  location;
33
34  if ( sig && !is_valid_signo(sig) )
35    set_errno_and_return_minus_one( EINVAL );
36
37/* commented out when posix timers added
38  if ( _POSIX_signals_Vectors[ sig ].sa_flags == SA_SIGINFO )
39    set_errno_and_return_minus_one( ENOSYS );
40*/
41
42  the_thread = _POSIX_Threads_Get( thread, &location );
43  switch ( location ) {
44    case OBJECTS_ERROR:
45    case OBJECTS_REMOTE:
46      set_errno_and_return_minus_one( ESRCH );
47    case OBJECTS_LOCAL:
48      /*
49       *  If sig == 0 then just validate arguments
50       */
51
52      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
53
54      if ( sig ) {
55
56        if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
57          _Thread_Enable_dispatch();
58          return 0;
59        }
60
61        /* XXX critical section */
62
63        api->signals_pending |= signo_to_mask( sig );
64
65        (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
66
67        the_thread->do_post_task_switch_extension = TRUE;
68
69        if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
70          _ISR_Signals_to_thread_executing = TRUE;
71      }
72      _Thread_Enable_dispatch();
73      return 0;
74  }
75
76  return POSIX_BOTTOM_REACHED();
77}
Note: See TracBrowser for help on using the repository browser.