| 17 | } |
| 18 | |
| 19 | int pthread_kill(pthread_t t, int sig) { |
| 20 | if (sig < 0 || sig >= _NSIG) { |
| 21 | return EINVAL; |
| 22 | } |
| 23 | if (!t || !_emscripten_thread_is_valid(t)) { |
| 24 | return ESRCH; |
| 25 | } |
| 26 | if (sig == 0) return 0; // signal == 0 is a no-op. |
| 27 | |
| 28 | // The job of pthread_kill is basically to run the (process-wide) signal |
| 29 | // handler on the target thread. |
| 30 | if (pthread_equal(pthread_self(), t)) { |
| 31 | raise(sig); |
| 32 | } else { |
| 33 | emscripten_proxy_async(emscripten_proxy_get_system_queue(), t, proxied_raise, (void*)(intptr_t)sig); |
| 34 | } |
| 35 | return 0; |
| 36 | } |