1 /* raise.c - Generic raise implementation.
2    Copyright (C) 2008-2022 Free Software Foundation, Inc.
3 
4    This file is part of the GNU Hurd.
5 
6    The GNU Hurd is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public License
8    as published by the Free Software Foundation; either version 3 of
9    the License, or (at your option) any later version.
10 
11    The GNU Hurd is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with this program.  If not, see
18    <https://www.gnu.org/licenses/>.  */
19 
20 #include <ldsodefs.h>
21 #include <pthreadP.h>
22 #include <signal.h>
23 #include <unistd.h>
24 
25 #pragma weak __pthread_kill
26 #pragma weak __pthread_self
27 #pragma weak __pthread_threads
28 
29 #ifndef SHARED
30 #pragma weak _dl_pthread_threads
31 #endif
32 
33 int
raise(int signo)34 raise (int signo)
35 {
36   /* According to POSIX, if we implement threads (and we do), then
37      "the effect of the raise() function shall be equivalent to
38      calling: pthread_kill(pthread_self(), sig);"  */
39 
40   if (__pthread_kill != NULL && GL (dl_pthread_threads) != NULL)
41     {
42       int err;
43       err = __pthread_kill (__pthread_self (), signo);
44       if (err)
45 	{
46 	  errno = err;
47 	  return -1;
48 	}
49       return 0;
50     }
51   else
52     return __kill (__getpid (), signo);
53 }
54 
55 libc_hidden_def (raise)
56 weak_alias (raise, gsignal)
57