fixed bug with cancelling sigwait threads

was not previously considering the possibility of
sigwait getting cancelled while processing a signal
which could leave locks in an invalid state. now the
code which cancels the thread waits until the sigwait
thread is waiting, then cancels the thread. when the
sigwait thread wakes up it calls pthread_testcancel
in order to exit at that point.