Back to index

glibc  2.9
raise.c File Reference
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <sysdep.h>
#include <nptl/pthreadP.h>
#include <kernel-features.h>

Go to the source code of this file.


int raise (int sig)

Function Documentation

int raise ( int  sig)

Definition at line 29 of file raise.c.

  struct pthread *pd = THREAD_SELF;
#if __ASSUME_TGKILL || defined __NR_tgkill
  pid_t pid = THREAD_GETMEM (pd, pid);
  pid_t selftid = THREAD_GETMEM (pd, tid);
  if (selftid == 0)
      /* This system call is not supposed to fail.  */
      selftid = INTERNAL_SYSCALL (gettid, err, 0);
      selftid = INLINE_SYSCALL (gettid, 0);
      THREAD_SETMEM (pd, tid, selftid);

#if __ASSUME_TGKILL || defined __NR_tgkill
      /* We do not set the PID field in the TID here since we might be
        called from a signal handler while the thread executes fork.  */
      pid = selftid;
#if __ASSUME_TGKILL || defined __NR_tgkill
    /* raise is an async-safe function.  It could be called while the
       fork/vfork function temporarily invalidated the PID field.  Adjust for
       that.  */
    if (__builtin_expect (pid <= 0, 0))
      pid = (pid & INT_MAX) == 0 ? selftid : -pid;

  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
# ifdef __NR_tgkill
  int res = INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
  if (res != -1 || errno != ENOSYS)
    return res;
# endif
  return INLINE_SYSCALL (tkill, 2, selftid, sig);

Here is the call graph for this function: