added Thread::mask_signal() function to mask around pthread_sigmask()
(couldn't call it sigmask() because that's a macro)
shar-utils.cpp:
shib-ccache.cpp:
block all signals in children threads, to make sure they don't
(improperly) handle signals, such as at SHAR Shutdown.
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@257
cb58f699-b61c-0410-a6fe-
9272a202ed29
shar_client_thread (void* arg)
{
SharChild* child = (SharChild*)arg;
+
+ // First, let's block all signals
+ sigset_t sigmask;
+ sigfillset(&sigmask);
+ Thread::mask_signals(SIG_BLOCK, &sigmask, NULL);
+
+ // the run the child until they exit.
child->run();
+
+ // now we can clean up and exit the thread.
delete child;
return NULL;
}
void* InternalCCache::cleanup_fcn(void* cache_p)
{
InternalCCache* cache = (InternalCCache*)cache_p;
+
+ // First, let's block all signals
+ sigset_t sigmask;
+ sigfillset(&sigmask);
+ Thread::mask_signals(SIG_BLOCK, &sigmask, NULL);
+
+ // Now run the cleanup process.
cache->cleanup();
}
pthread_exit (return_val);
}
+int Thread::mask_signals(int how, const sigset_t *newmask, sigset_t *oldmask)
+{
+ return pthread_sigmask(how,newmask,oldmask);
+}
+
Mutex * Mutex::create()
{
return new MutexImpl();
#ifdef __cplusplus
#include <time.h>
+#include <signal.h>
namespace shibtarget {
public:
static Thread* create(void* (*start_routine)(void*), void* arg);
static void exit(void* return_val);
+ static int mask_signals(int how, const sigset_t *newmask, sigset_t *oldmask);
virtual int detach() = 0;
virtual int join(void** thread_return) = 0;