source: rtems/cpukit/posix/src/pthreadkill.c @ 92f4671

4.104.115
Last change on this file since 92f4671 was f8437c8, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 15:23:12

Convert to "bool".

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