source: rtems/cpukit/posix/src/pthreadkill.c @ dbb30e26

5
Last change on this file since dbb30e26 was e266d13, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 13:10:27

Replace *_Get_interrupt_disable() with *_Get()

Uniformly use *_Get() to get an object by identifier with a lock
context.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Sends a signal Asynchronously directed to a thread
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  3.3.10 Send a Signal to a Thread, P1003.1c/D10, p. 43
10 *
11 *  COPYRIGHT (c) 1989-2007.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <pthread.h>
24#include <signal.h>
25#include <errno.h>
26
27#include <rtems/posix/threadsup.h>
28#include <rtems/posix/psignalimpl.h>
29#include <rtems/score/threadimpl.h>
30
31int pthread_kill( pthread_t thread, int sig )
32{
33  Thread_Control    *the_thread;
34  ISR_lock_Context   lock_context;
35  POSIX_API_Control *api;
36  Per_CPU_Control   *cpu_self;
37
38  if ( !is_valid_signo( sig ) ) {
39    return EINVAL;
40  }
41
42  the_thread = _Thread_Get( thread, &lock_context );
43
44  if ( the_thread == NULL ) {
45    return ESRCH;
46  }
47
48  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
49
50  if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
51    _ISR_lock_ISR_enable( &lock_context );
52    return 0;
53  }
54
55  /* XXX critical section */
56
57  api->signals_pending |= signo_to_mask( sig );
58
59  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
60  _ISR_lock_ISR_enable( &lock_context );
61
62  (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
63  _Thread_Dispatch_enable( cpu_self );
64  return 0;
65}
Note: See TracBrowser for help on using the repository browser.