diff options
author | Chris Hall (GMCH) <chris.hall@highwayman.com> | 2009-12-03 20:06:55 +0000 |
---|---|---|
committer | Chris Hall (GMCH) <chris.hall@highwayman.com> | 2009-12-03 20:06:55 +0000 |
commit | 606acaa3264d6868ad06d1874137c6aa81ad14e5 (patch) | |
tree | 8f781310aa3e3cc99ed018419973bcf60a6b3d90 /lib/qpthreads.c | |
parent | 9cd302528c2db501744694d8572cb4e658bf4259 (diff) | |
download | quagga-606acaa3264d6868ad06d1874137c6aa81ad14e5.tar.bz2 quagga-606acaa3264d6868ad06d1874137c6aa81ad14e5.tar.xz |
Add signal functions to lib/qpthreads.c
Adding qpt_thread_sigmask() and qpt_thread_signal().
Diffstat (limited to 'lib/qpthreads.c')
-rw-r--r-- | lib/qpthreads.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/qpthreads.c b/lib/qpthreads.c index 87ee00d3..61ad80fc 100644 --- a/lib/qpthreads.c +++ b/lib/qpthreads.c @@ -19,6 +19,8 @@ * Boston, MA 02111-1307, USA. */ +#include <signal.h> + #include "qpthreads.h" #include "memory.h" @@ -118,6 +120,14 @@ * * The use a clock other than Quagga's standard (QPT_COND_CLOCK_ID) is possible, * but not recommended. (See qpthreads.h for discussion of this.) + * + * Pthread Specific Signal Handling + * ================================ + * + * In a threaded application, need to use pthread_sigmask (not sigproc_mask). + * (Can use pthread_sigmask in a single threaded application.) + * + * To direct a signal at a given thread need pthread_kill. * */ /*============================================================================== @@ -433,3 +443,39 @@ qpt_cond_destroy(qpt_cond_t* cv, int free_cond) return NULL ; } ; + +/*============================================================================== + * Signal Handling. + */ + +/* Set thread signal mask + * + * Thin wrapper around pthread_sigmask. + * + * zaborts if gets any error. + */ +void +qpt_thread_sigmask(int how, const sigset_t* set, sigset_t* oset) +{ + int err ; + + err = pthread_sigmask(how, set, oset) ; + if (err != 0) + zabort_err("pthread_sigmask failed", err) ; +} ; + +/* Send given thread the given signal + * + * Thin wrapper around pthread_kill. + * + * zaborts if gets any error. + */ +void +qpt_thread_signal(qpt_thread_t thread, int signum) +{ + int err ; + + err = pthread_kill(thread, signum) ; + if (err != 0) + zabort_err("pthread_kill failed", err) ; +} ; |