| 78 | void Thread::resume() { sendSignal(-2); } |
| 79 | |
| 80 | void Thread::sendSignal(int signo) { |
| 81 | if (signo >= 0) { |
| 82 | if (!sigMask.test(signo)) { |
| 83 | return; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // TODO: suspend uses another delivery confirmation |
| 88 | if (signo != -1) { |
| 89 | interruptedMtx.store(1, std::memory_order::release); |
| 90 | |
| 91 | if (pthread_sigqueue(getNativeHandle(), SIGUSR1, {.sival_int = signo})) { |
| 92 | perror("pthread_sigqueue"); |
| 93 | } |
| 94 | |
| 95 | while (interruptedMtx.wait(1, std::chrono::microseconds(1000)) != |
| 96 | std::errc{}) { |
| 97 | if (interruptedMtx.load() == 0) { |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | if (pthread_sigqueue(getNativeHandle(), SIGUSR1, {.sival_int = -2})) { |
| 102 | perror("pthread_sigqueue"); |
| 103 | } |
| 104 | } |
| 105 | } else { |
| 106 | if (pthread_sigqueue(getNativeHandle(), SIGUSR1, {.sival_int = signo})) { |
| 107 | perror("pthread_sigqueue"); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | void Thread::notifyUnblockedSignal(int signo) { |
| 113 | for (std::size_t i = 0; i < blockedSignals.size();) { |