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);
37 for (i = 0; i < NSIG; i++)
38 if (softsig_sigs[i].pending) {
39 softsig_sigs[i].pending = 0;
40 h = softsig_sigs[i].handler;
45 assert (0 == sigwait (&ss, &sigw));
57 sigaddset (&ss, SIGUSR1);
59 /* Set mask right away, so we don't accidentally SIGUSR1 the
60 * softsig thread and cause an exit (default action).
62 assert (0 == pthread_sigmask (SIG_BLOCK, &ss, &os));
63 assert (0 == pthread_create (&softsig_tid, NULL, &softsig_thread, NULL));
64 assert (0 == pthread_sigmask (SIG_SETMASK, &os, NULL));
68 softsig_handler (int signo)
70 softsig_sigs[signo].pending = 1;
71 pthread_kill (softsig_tid, SIGUSR1);
75 softsig_signal (int signo, void (*handler) (int))
77 softsig_sigs[signo].handler = handler;
78 signal (signo, softsig_handler);
85 printf ("foo, signo = %d, tid = %d\n", signo, pthread_self ());
92 softsig_signal (SIGINT, print_foo);
93 printf ("main is tid %d\n", pthread_self ());