hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/unix/sysv/linux/raise.c

Packit 6c4009
/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <signal.h>
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <errno.h>
Packit 6c4009
#include <sys/types.h>
Packit 6c4009
#include <unistd.h>
Packit 6c4009
#include <internal-signals.h>
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
raise (int sig)
Packit 6c4009
{
Packit 6c4009
  /* rt_sigprocmask may fail if:
Packit 6c4009
Packit 6c4009
     1. sigsetsize != sizeof (sigset_t) (EINVAL)
Packit 6c4009
     2. a failure in copy from/to user space (EFAULT)
Packit 6c4009
     3. an invalid 'how' operation (EINVAL)
Packit 6c4009
Packit 6c4009
     The first case is already handle in glibc syscall call by using the arch
Packit 6c4009
     defined _NSIG.  Second case is handled by using a stack allocated mask.
Packit 6c4009
     The last one should be handled by the block/unblock functions.  */
Packit 6c4009
Packit 6c4009
  sigset_t set;
Packit 6c4009
  __libc_signal_block_app (&set);
Packit 6c4009
Packit 6c4009
  INTERNAL_SYSCALL_DECL (err);
Packit 6c4009
  pid_t pid = INTERNAL_SYSCALL (getpid, err, 0);
Packit 6c4009
  pid_t tid = INTERNAL_SYSCALL (gettid, err, 0);
Packit 6c4009
Packit 6c4009
  int ret = INLINE_SYSCALL (tgkill, 3, pid, tid, sig);
Packit 6c4009
Packit 6c4009
  __libc_signal_restore_set (&set);
Packit 6c4009
Packit 6c4009
  return ret;
Packit 6c4009
}
Packit 6c4009
libc_hidden_def (raise)
Packit 6c4009
weak_alias (raise, gsignal)