Work around broken `sigprocmask()` and `siglongjmp()` on macOS.
Apparently, `sigprocmask()` on macOS affects all threads. You must use `pthread_sigmask()` to affect only the current thread. (To be fair, POSIX says that `sigprocmask()` has unspecified behavior in the presence of threads. However, having it affect all threads is bizarre. On Linux, it affects only the calling thread.) Moreover, `siglongjmp()` on macOS is implemented in terms of `sigprocmask()`. Hence, `siglongjmp()` (with `true` for the second parameter) is not safe to use in a multithreaded program. Instead, we must decompose `siglongjmp()` into its component parts, so that we can correctly use `pthread_sigmask()`. This fixes the deadlocks on macOS.
Showing
Please
register
or
sign in
to comment