source: rtems/c/src/exec/posix/src/pthreadkill.c @ f42b726

4.104.114.84.95
Last change on this file since f42b726 was f42b726, checked in by Joel Sherrill <joel.sherrill@…>, on 01/24/01 at 14:17:28

2001-01-24 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/config.h
  • src/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/.cvsignore: Add config.h and stamp-h
  • src/*.c: Add config.h support.
  • 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-1999.
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.OARcorp.com/rtems/license.html.
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 && !is_valid_signo(sig) )
38    set_errno_and_return_minus_one( EINVAL );
39
40/* commented out when posix timers added
41  if ( _POSIX_signals_Vectors[ sig ].sa_flags == SA_SIGINFO )
42    set_errno_and_return_minus_one( ENOSYS );
43*/
44
45  the_thread = _POSIX_Threads_Get( thread, &location );
46  switch ( location ) {
47    case OBJECTS_ERROR:
48    case OBJECTS_REMOTE:
49      set_errno_and_return_minus_one( ESRCH );
50    case OBJECTS_LOCAL:
51      /*
52       *  If sig == 0 then just validate arguments
53       */
54
55      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
56
57      if ( sig ) {
58
59        if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
60          _Thread_Enable_dispatch();
61          return 0;
62        }
63
64        /* XXX critical section */
65
66        api->signals_pending |= signo_to_mask( sig );
67
68        (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
69
70        the_thread->do_post_task_switch_extension = TRUE;
71
72        if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
73          _ISR_Signals_to_thread_executing = TRUE;
74      }
75      _Thread_Enable_dispatch();
76      return 0;
77  }
78
79  return POSIX_BOTTOM_REACHED();
80}
Note: See TracBrowser for help on using the repository browser.