2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #define _POSIX_PTHREAD_SEMANTICS
11 #include <afs/param.h>
18 #include <afs/procmgmt.h>
22 #include "pthread_nosigs.h"
24 static pthread_t softsig_tid;
26 void (*handler) (int);
33 softsig_thread (void *arg)
39 /* get the list of signals _not_ blocked by AFS_SIGSET_CLEAR() */
40 pthread_sigmask (SIG_BLOCK, &ss, &os);
41 pthread_sigmask (SIG_SETMASK, &os, NULL);
42 sigaddset (&ss, SIGUSR1);
43 for (i = 0; i < NSIG; i++) {
44 if (!sigismember(&os, i) && i != SIGSTOP && i != SIGKILL) {
46 softsig_sigs[i].fatal = 1;
56 for (i = 0; i < NSIG; i++) {
57 if (softsig_sigs[i].handler && !softsig_sigs[i].inited) {
59 softsig_sigs[i].inited = 1;
61 if (softsig_sigs[i].pending) {
62 softsig_sigs[i].pending = 0;
63 h = softsig_sigs[i].handler;
69 if (sigw != SIGUSR1) {
70 if (softsig_sigs[sigw].fatal)
72 softsig_sigs[sigw].pending=1;
85 rc = pthread_create (&softsig_tid, NULL, &softsig_thread, NULL);
91 softsig_handler (int signo)
93 signal (signo, softsig_handler);
94 softsig_sigs[signo].pending = 1;
95 pthread_kill (softsig_tid, SIGUSR1);
99 softsig_signal (int signo, void (*handler) (int))
101 softsig_sigs[signo].handler = handler;
102 softsig_sigs[signo].inited = 0;
103 signal (signo, softsig_handler);
104 pthread_kill (softsig_tid, SIGUSR1);
109 print_foo (int signo)
111 printf ("foo, signo = %d, tid = %d\n", signo, pthread_self ());
118 softsig_signal (SIGINT, print_foo);
119 printf ("main is tid %d\n", pthread_self ());