Fix parameter name.
[glibc/pb-stable.git] / linuxthreads / sighandler.c
blobab8b38e539a60ac26b62432a3af82cf4fea8cd0d
1 /* Linuxthreads - a simple clone()-based implementation of Posix */
2 /* threads for Linux. */
3 /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
4 /* */
5 /* This program is free software; you can redistribute it and/or */
6 /* modify it under the terms of the GNU Library General Public License */
7 /* as published by the Free Software Foundation; either version 2 */
8 /* of the License, or (at your option) any later version. */
9 /* */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU Library General Public License for more details. */
15 /* Signal handlers */
17 #include "internals.h"
20 /* The wrapper around user-provided signal handlers */
21 void __pthread_sighandler(int signo, SIGCONTEXT ctx)
23 pthread_descr self;
24 char * in_sighandler;
25 self = thread_self();
26 /* If we're in a sigwait operation, just record the signal received
27 and return without calling the user's handler */
28 if (THREAD_GETMEM(self, p_sigwaiting)) {
29 THREAD_SETMEM(self, p_sigwaiting, 0);
30 THREAD_SETMEM(self, p_signal, signo);
31 return;
33 /* Record that we're in a signal handler and call the user's
34 handler function */
35 in_sighandler = THREAD_GETMEM(self, p_in_sighandler);
36 if (in_sighandler == NULL)
37 THREAD_SETMEM(self, p_in_sighandler, CURRENT_STACK_FRAME);
38 CALL_SIGHANDLER(__sighandler[signo].old, signo, ctx);
39 if (in_sighandler == NULL)
40 THREAD_SETMEM(self, p_in_sighandler, NULL);
43 /* The same, this time for real-time signals. */
44 void __pthread_sighandler_rt(int signo, struct siginfo *si,
45 struct ucontext *uc)
47 pthread_descr self;
48 char * in_sighandler;
49 self = thread_self();
50 /* If we're in a sigwait operation, just record the signal received
51 and return without calling the user's handler */
52 if (THREAD_GETMEM(self, p_sigwaiting)) {
53 THREAD_SETMEM(self, p_sigwaiting, 0);
54 THREAD_SETMEM(self, p_signal, signo);
55 return;
57 /* Record that we're in a signal handler and call the user's
58 handler function */
59 in_sighandler = THREAD_GETMEM(self, p_in_sighandler);
60 if (in_sighandler == NULL)
61 THREAD_SETMEM(self, p_in_sighandler, CURRENT_STACK_FRAME);
62 __sighandler[signo].rt(signo, si, uc);
63 if (in_sighandler == NULL)
64 THREAD_SETMEM(self, p_in_sighandler, NULL);
68 /* A signal handler that does nothing */
69 void __pthread_null_sighandler(int sig) { }