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
17 static pthread_t softsig_tid;
19 void (*handler) (int);
24 softsig_thread (void *arg)
29 sigaddset (&ss, SIGUSR1);
32 void (*h) (int) = NULL;
35 for (i = 0; i < NSIG; i++)
36 if (softsig_sigs[i].pending) {
37 softsig_sigs[i].pending = 0;
38 h = softsig_sigs[i].handler;
43 assert (0 == sigwait (&ss, &sigw));
55 sigaddset (&ss, SIGUSR1);
57 /* Set mask right away, so we don't accidentally SIGUSR1 the
58 * softsig thread and cause an exit (default action).
60 assert (0 == pthread_sigmask (SIG_BLOCK, &ss, &os));
61 assert (0 == pthread_create (&softsig_tid, NULL, &softsig_thread, NULL));
62 assert (0 == pthread_sigmask (SIG_SETMASK, &os, NULL));
66 softsig_handler (int signo)
68 softsig_sigs[signo].pending = 1;
69 pthread_kill (softsig_tid, SIGUSR1);
73 softsig_signal (int signo, void (*handler) (int))
75 softsig_sigs[signo].handler = handler;
76 signal (signo, softsig_handler);
83 printf ("foo, signo = %d, tid = %d\n", signo, pthread_self ());
90 softsig_signal (SIGINT, print_foo);
91 printf ("main is tid %d\n", pthread_self ());