Signals delivery is generally not deterministic in multi-threaded programs,
but SIGSEGV is always sent by the kernel to the thread which caused the fault.
Replaced the global signal handler array by a pointer in the per-thread
context and replaced saving of original handles (which was wrong even in
some non-threaded cases) by locked use counters.
Also moved logging of the SIGSEGV error message out of the signal handler
to be sure there are no clashes.
When libucw is compiled without threading, everything is nearly as simple
as before, because the thread context struct is static and all locks
disappear.