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 static pthread_t softsig_tid;
24 void (*handler) (int);
29 softsig_thread (void *arg)
34 sigaddset (&ss, SIGUSR1);
42 for (i = 0; i < NSIG; i++)
43 if (softsig_sigs[i].pending) {
44 softsig_sigs[i].pending = 0;
45 h = softsig_sigs[i].handler;
50 assert (0 == sigwait (&ss, &sigw));
62 sigaddset (&ss, SIGUSR1);
64 /* Set mask right away, so we don't accidentally SIGUSR1 the
65 * softsig thread and cause an exit (default action).
67 assert (0 == pthread_sigmask (SIG_BLOCK, &ss, &os));
68 assert (0 == pthread_create (&softsig_tid, NULL, &softsig_thread, NULL));
69 assert (0 == pthread_sigmask (SIG_SETMASK, &os, NULL));
73 softsig_handler (int signo)
75 softsig_sigs[signo].pending = 1;
76 pthread_kill (softsig_tid, SIGUSR1);
80 softsig_signal (int signo, void (*handler) (int))
82 softsig_sigs[signo].handler = handler;
83 signal (signo, softsig_handler);
90 printf ("foo, signo = %d, tid = %d\n", signo, pthread_self ());
97 softsig_signal (SIGINT, print_foo);
98 printf ("main is tid %d\n", pthread_self ());