* Establishes the exit signal masks and handlers. */
| 66 | * Establishes the exit signal masks and handlers. |
| 67 | */ |
| 68 | bool CatchExitSignal() { |
| 69 | if (!ProcessMasks.initialized) { |
| 70 | struct sigaction sa; |
| 71 | memset(&sa, 0, sizeof(sa)); |
| 72 | sa.sa_handler = ExitRequestHandler; |
| 73 | if (sigaction(SIG_THREAD_EXIT, &sa, NULL) < 0) { |
| 74 | return false; |
| 75 | } |
| 76 | sigfillset(&ProcessMasks.allmask); // complete blockage of everything |
| 77 | sigfillset(&ProcessMasks.mostmask); // block all except SIG_THREAD_EXIT |
| 78 | sigdelset(&ProcessMasks.mostmask, SIG_THREAD_EXIT); |
| 79 | |
| 80 | ProcessMasks.initialized = true; |
| 81 | } |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | // pthread_sigmask shouldn't return EINTR, but we can check. |
| 86 | static inline void PthreadSetSigmask(const sigset_t *mask) { |